PropertySetStatementFilter   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 6
c 3
b 0
f 0
dl 0
loc 29
ccs 6
cts 6
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A statementMatches() 0 3 1
A __construct() 0 2 1
1
<?php
2
3
namespace Wikibase\DataModel\Services\Statement\Filter;
4
5
use Wikibase\DataModel\Statement\Statement;
6
use Wikibase\DataModel\Statement\StatementFilter;
7
8
/**
9
 * A filter that only accepts statements with specific property ids, and rejects all other
10
 * properties.
11
 *
12
 * @since 3.2
13
 *
14
 * @license GPL-2.0-or-later
15
 * @author Thiemo Kreuz
16
 */
17
class PropertySetStatementFilter implements StatementFilter {
18
19
	/**
20
	 * @since 3.3
21
	 */
22
	public const FILTER_TYPE = 'propertySet';
23
24 9
	/**
25 9
	 * @var string[]
26 9
	 */
27
	private $propertyIds;
28
29
	/**
30
	 * @param string[]|string $propertyIds One or more property id serializations.
31
	 */
32
	public function __construct( $propertyIds ) {
33
		$this->propertyIds = (array)$propertyIds;
34
	}
35 9
36 9
	/**
37 9
	 * @see StatementFilter::statementMatches
38
	 *
39
	 * @param Statement $statement
40
	 *
41
	 * @return bool
42
	 */
43
	public function statementMatches( Statement $statement ) {
44
		$id = $statement->getPropertyId()->getSerialization();
45
		return in_array( $id, $this->propertyIds );
46
	}
47
48
}
49