SimpleStatement::newInstance()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Queryr\Resources;
4
5
use DataValues\DataValue;
6
use Wikibase\DataModel\Entity\PropertyId;
7
8
/**
9
 * @licence GNU GPL v2+
10
 * @author Jeroen De Dauw < [email protected] >
11
 */
12
class SimpleStatement {
13
14
	/**
15
	 * @var string
16
	 */
17
	public $propertyName;
18
19
	/**
20
	 * @var PropertyId
21
	 */
22
	public $propertyId;
23
24
	/**
25
	 * @var string
26
	 */
27
	public $valueType;
28
29
	/**
30
	 * Should have at least one element.
31
	 *
32
	 * @var DataValue[]
33
	 */
34
	public $values = [];
35
36
	public static function newInstance() {
37
		return new self();
38
	}
39
40
	public function withPropertyName( $propertyName ) {
41
		$this->propertyName = $propertyName;
42
		return $this;
43
	}
44
45
	public function withType( $type ) {
46
		$this->valueType = $type;
47
		return $this;
48
	}
49
50
	public function withValues( array $values ) {
51
		$this->values = $values;
52
		return $this;
53
	}
54
55
	public function withPropertyId( $propertyId ) {
56
		$this->propertyId = is_string( $propertyId ) ? new PropertyId( $propertyId ) : $propertyId;
57
		return $this;
58
	}
59
60
}