| 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: | return $this->coredata ?: $this->coredata = new AbstractCoredata($this->data['coredata']); |
| 27: | } |
| 28: | |
| 29: | |
| 30: | |
| 31: | |
| 32: | public function getAuthors() |
| 33: | { |
| 34: | if (isset($this->data['authors']['author'])) { |
| 35: | return $this->authors ?: $this->authors = array_map(function($author) { |
| 36: | return new AbstractAuthor($author); |
| 37: | }, $this->data['authors']['author']); |
| 38: | } |
| 39: | } |
| 40: | |
| 41: | |
| 42: | |
| 43: | |
| 44: | public function countAuthors() |
| 45: | { |
| 46: | return isset($this->data['authors']['author']) ? count($this->data['authors']['author']) : 0; |
| 47: | } |
| 48: | |
| 49: | public function getItem() |
| 50: | { |
| 51: | return $this->item ?: $this->item = new AbstractItem($this->data['item']); |
| 52: | } |
| 53: | } |