Passed
Push — master ( 3a7c7a...fe0bb9 )
by Sam
03:04
created

Property::getReferences()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3.7085

Importance

Changes 0
Metric Value
cc 3
eloc 6
nc 3
nop 0
dl 0
loc 9
ccs 4
cts 7
cp 0.5714
crap 3.7085
rs 9.6666
c 0
b 0
f 0
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 2
		public function __construct( $claim, $lang, $cache ) {
19 2
		$this->claim = $claim;
20 2
		$this->lang = $lang;
21 2
		$this->cache = $cache;
22 2
	 }
23
24
	/**
25
	 * @return Reference[]
26
	 */
27 1
	public function getReferences() {
28 1
		$references = [];
29 1
		if ( !isset( $this->claim['references'] ) ) {
30 1
			return $references;
31
		}
32
		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...
33
			$references[] = new Reference( $ref, $this->lang, $this->cache );
34
		}
35
		return $references;
36
	}
37
}
38