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

MainSnakContextCursor   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 80
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 1
dl 0
loc 80
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 1
A getType() 0 3 1
A getEntityId() 0 3 1
A getStatementPropertyId() 0 3 1
A getStatementGuid() 0 3 1
A getSnakPropertyId() 0 3 1
A getSnakHash() 0 3 1
A getMainArray() 0 11 2
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