Completed
Push — master ( 1b65e5...7464ba )
by
unknown
02:16
created

MainSnakContextCursor::getEntityId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Context;
4
5
/**
6
 * @license GPL-2.0-or-later
7
 */
8
class MainSnakContextCursor extends ApiV2ContextCursor {
9
10
	/**
11
	 * @var string
12
	 */
13
	private $entityId;
14
15
	/**
16
	 * @var string
17
	 */
18
	private $statementPropertyId;
19
20
	/**
21
	 * @var string
22
	 */
23
	private $statementGuid;
24
25
	/**
26
	 * @var string
27
	 */
28
	private $snakHash;
29
30
	/**
31
	 * @param string $entityId
32
	 * @param string $statementPropertyId
33
	 * @param string $statementGuid
34
	 * @param string $snakHash
35
	 */
36
	public function __construct(
37
		$entityId,
38
		$statementPropertyId,
39
		$statementGuid,
40
		$snakHash
41
	) {
42
		$this->entityId = $entityId;
43
		$this->statementPropertyId = $statementPropertyId;
44
		$this->statementGuid = $statementGuid;
45
		$this->snakHash = $snakHash;
46
	}
47
48
	/**
49
	 * @codeCoverageIgnore This method is purely declarative.
50
	 */
51
	public function getType() {
52
		return Context::TYPE_STATEMENT;
53
	}
54
55
	public function getEntityId() {
56
		return $this->entityId;
57
	}
58
59
	public function getStatementPropertyId() {
60
		return $this->statementPropertyId;
61
	}
62
63
	public function getStatementGuid() {
64
		return $this->statementGuid;
65
	}
66
67
	public function getSnakPropertyId() {
68
		return $this->statementPropertyId;
69
	}
70
71
	public function getSnakHash() {
72
		return $this->snakHash;
73
	}
74
75
	protected function &getMainArray( array &$container ) {
76
		$statementArray = &$this->getStatementArray( $container );
77
78
		if ( !array_key_exists( 'mainsnak', $statementArray ) ) {
79
			$snakHash = $this->getSnakHash();
80
			$statementArray['mainsnak'] = [ 'hash' => $snakHash ];
81
		}
82
		$mainsnakArray = &$statementArray['mainsnak'];
83
84
		return $mainsnakArray;
85
	}
86
87
}
88