Property::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 4
ccs 0
cts 4
cp 0
crap 2
rs 10
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
The expression $this->claim['references'] of type string is not traversable.
Loading history...
38
			$references[] = new Reference( $ref, $this->lang, $this->cache );
39
		}
40
		return $references;
41
	}
42
}
43