Property::getReferences()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 6
c 1
b 0
f 0
nc 3
nop 0
dl 0
loc 9
ccs 0
cts 7
cp 0
crap 12
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