1: <?php
2:
3: namespace Scopus\Response;
4:
5: class Author
6: {
7:
8: protected $data;
9:
10:
11: protected $affiliation;
12:
13:
14: protected $affiliation_history;
15:
16:
17: protected $profile;
18:
19: public function __construct(array $data)
20: {
21: $this->data = $data;
22: }
23:
24: public function getAffiliation()
25: {
26: return $this->affiliation ?: $this->affiliation = new Affiliation($this->prepareAffiliationData($this->data['affiliation-current']));
27: }
28:
29: public function getAffiliationHistory()
30: {
31: if (isset($this->data['affiliation-history'])) {
32: return $this->affiliation_history ?: $this->affiliation_history = array_map(function($affiliation) {
33: return new Affiliation($this->prepareAffiliationData($affiliation));
34: }, $this->data['affiliation-history']);
35: }
36: }
37:
38: public function getProfile()
39: {
40: if (isset($this->data['author-profile'])) {
41: return $this->profile ?: $this->profile = new AuthorProfile($this->data['author-profile']);
42: }
43: }
44:
45: protected function prepareAffiliationData($affiliation)
46: {
47: return [
48: 'afid' => $affiliation['@id'],
49: 'affiliation-url' => $affiliation['@href']
50: ];
51: }
52:
53: }