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: public function __construct(array $data)
17: {
18: $this->data = $data;
19: }
20:
21: public function getPreferredName()
22: {
23: return $this->preferredName ?: $this->preferredName = new AuthorName($this->data['preferred-name']);
24: }
25:
26: public function getNameVariants()
27: {
28: return $this->nameVariants ?: $this->nameVariants = array_map(function($nameVariant) {
29: return new AuthorName($nameVariant);
30: }, isset($this->data['name-variant']) ?
31: isset($this->data['name-variant']['indexed-name']) ? [$this->data['name-variant']] : $this->data['name-variant'] :
32: []);
33: }
34: }