| 1: | <?php |
| 2: | |
| 3: | namespace Scopus\Response; |
| 4: | |
| 5: | class Abstracts implements IAbstract |
| 6: | { |
| 7: | |
| 8: | protected $data; |
| 9: | |
| 10: | |
| 11: | protected $coredata; |
| 12: | |
| 13: | |
| 14: | protected $authors; |
| 15: | |
| 16: | |
| 17: | protected $item; |
| 18: | |
| 19: | public function __construct(array $data) |
| 20: | { |
| 21: | $this->data = $data; |
| 22: | } |
| 23: | |
| 24: | public function getCoredata() |
| 25: | { |
| 26: | if (!isset($this->data['coredata'])) { |
| 27: | return null; |
| 28: | } |
| 29: | |
| 30: | return $this->coredata ?? $this->coredata = new AbstractCoredata($this->data['coredata']); |
| 31: | } |
| 32: | |
| 33: | |
| 34: | |
| 35: | |
| 36: | public function getAuthors(): array |
| 37: | { |
| 38: | if (isset($this->data['authors']['author'])) { |
| 39: | return $this->authors ?? $this->authors = array_map(function($author) { |
| 40: | return new AbstractAuthor($author); |
| 41: | }, $this->data['authors']['author']); |
| 42: | } |
| 43: | |
| 44: | return []; |
| 45: | } |
| 46: | |
| 47: | |
| 48: | |
| 49: | |
| 50: | public function countAuthors() |
| 51: | { |
| 52: | return count($this->getAuthors()); |
| 53: | } |
| 54: | |
| 55: | public function getItem() |
| 56: | { |
| 57: | if (!isset($this->data['item'])) { |
| 58: | return null; |
| 59: | } |
| 60: | |
| 61: | return $this->item ?? $this->item = new AbstractItem($this->data['item']); |
| 62: | } |
| 63: | } |