InMemoryEntityTermStore::unsetTerms()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Wikibase\TermStore\MediaWiki\PackagePrivate;
4
5
use Wikibase\DataModel\Entity\EntityId;
6
7
/**
8
 * in-memory, @inheritDoc
9
 */
10
class InMemoryEntityTermStore implements EntityTermStore {
11
	private $entityTerms = [];
12
13
	public function setTerms( EntityId $entityId, array $termsArray ) {
14
		$this->entityTerms[$entityId->getSerialization()] = $termsArray;
15
	}
16
17
	public function unsetTerms( EntityId $entityId ) {
18
		unset( $this->entityTerms[$entityId->getSerialization()] );
19
	}
20
21
	/**
22
	 * check that terms for the given entity id has the given terms stored
23
	 *
24
	 * @param EntityId $entityId
25
	 * @param array $termsArray same as $termsArray for InMemoryEntityTermStore::setTerms()
26
	 *
27
	 * @return bool
28
	 */
29
	public function hasExactTerms( EntityId $entityId, array $termsArray ) {
30
		if ( !isset( $this->entityTerms[$entityId->getSerialization()] ) ) {
31
			return false;
32
		}
33
34
		return $termsArray === $this->entityTerms[$entityId->getSerialization()];
35
	}
36
37
	/**
38
	 * Check that given entity id has no terms stored
39
	 *
40
	 * @return bool
41
	 */
42
	public function hasNoTerms( EntityId $entityId ) {
43
		return !isset( $this->entityTerms[$entityId->getSerialization()] );
44
	}
45
46
}
47