samwilson /
simple-wikidata
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Samwilson\SimpleWikidata; |
||
| 4 | |||
| 5 | use Psr\Cache\CacheItemPoolInterface; |
||
| 6 | |||
| 7 | abstract class Property { |
||
| 8 | |||
| 9 | /** @var string[] */ |
||
| 10 | protected $claim; |
||
| 11 | |||
| 12 | /** @var string */ |
||
| 13 | protected $lang; |
||
| 14 | |||
| 15 | /** @var CacheItemPoolInterface */ |
||
| 16 | protected $cache; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @param string $claim The claim data array. |
||
| 20 | * @param string $lang The language code. |
||
| 21 | * @param CacheItemPoolInterface $cache |
||
| 22 | */ |
||
| 23 | public function __construct( array $claim, $lang, CacheItemPoolInterface $cache ) { |
||
| 24 | $this->claim = $claim; |
||
| 25 | $this->lang = $lang; |
||
| 26 | $this->cache = $cache; |
||
| 27 | } |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @return Reference[] |
||
| 31 | */ |
||
| 32 | public function getReferences() { |
||
| 33 | $references = []; |
||
| 34 | if ( !isset( $this->claim['references'] ) ) { |
||
| 35 | return $references; |
||
| 36 | } |
||
| 37 | foreach ( $this->claim['references'] as $ref ) { |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 38 | $references[] = new Reference( $ref, $this->lang, $this->cache ); |
||
| 39 | } |
||
| 40 | return $references; |
||
| 41 | } |
||
| 42 | } |
||
| 43 |