| 1: | <?php |
| 2: | |
| 3: | namespace Scopus\Response; |
| 4: | |
| 5: | class AuthorProfile |
| 6: | { |
| 7: | |
| 8: | protected $data; |
| 9: | |
| 10: | |
| 11: | protected $preferredName; |
| 12: | |
| 13: | |
| 14: | protected $nameVariants; |
| 15: | |
| 16: | |
| 17: | protected $journalHistory; |
| 18: | |
| 19: | |
| 20: | protected $affiliationCurrent; |
| 21: | |
| 22: | public function __construct(array $data) |
| 23: | { |
| 24: | $this->data = $data; |
| 25: | } |
| 26: | |
| 27: | public function getDataCreated() |
| 28: | { |
| 29: | if (isset($this->data['date-created'])) { |
| 30: | $dateCreat = $this->data['date-created']; |
| 31: | return $dateCreat['@year'] . '-' . $dateCreat['@month'] . '-' . $dateCreat['@day']; |
| 32: | } |
| 33: | return null; |
| 34: | } |
| 35: | |
| 36: | public function getPreferredName() |
| 37: | { |
| 38: | return $this->preferredName ?: $this->preferredName = new AuthorName($this->data['preferred-name']); |
| 39: | } |
| 40: | |
| 41: | public function getNameVariants() |
| 42: | { |
| 43: | return $this->nameVariants ?: $this->nameVariants = array_map(function ($nameVariant) { |
| 44: | return new AuthorName($nameVariant); |
| 45: | }, isset($this->data['name-variant']) ? |
| 46: | isset($this->data['name-variant']['indexed-name']) ? [$this->data['name-variant']] : $this->data['name-variant'] : []); |
| 47: | } |
| 48: | |
| 49: | |
| 50: | |
| 51: | public function getPublicationRange() |
| 52: | { |
| 53: | if (isset($this->data['publication-range'])) { |
| 54: | $pubRange = $this->data['publication-range']; |
| 55: | return $pubRange['@start'] . '-' . $pubRange['@end']; |
| 56: | } |
| 57: | return null; |
| 58: | } |
| 59: | |
| 60: | |
| 61: | public function getJournalHistory() |
| 62: | { |
| 63: | if (isset($this->data['journal-history'])) { |
| 64: | return $this->journalHistory ?: $this->journalHistory = array_map(function ($journal) { |
| 65: | return new Journal($this->prepareJournalHistory($journal)); |
| 66: | }, $this->data['journal-history']); |
| 67: | } |
| 68: | } |
| 69: | |
| 70: | protected function prepareJournalHistory($journal) |
| 71: | { |
| 72: | return [ |
| 73: | 'type' => $journal['@type'] |
| 74: | ]; |
| 75: | } |
| 76: | |
| 77: | public function getAffiliationCurrent() |
| 78: | { |
| 79: | $affiliation = (array_key_exists(0, $this->data['affiliation-current']['affiliation'])) ? $this->data['affiliation-current']['affiliation'][0] : $this->data['affiliation-current']['affiliation']; |
| 80: | return $this->affiliationCurrent ?: $this->affiliationCurrent = new AuthorAffiliation($affiliation); |
| 81: | } |
| 82: | |
| 83: | |
| 84: | |
| 85: | } |
| 86: | |