TermStoreEntityHandler::handleEntity()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
1
<?php
2
3
namespace Queryr\Replicator\Importer\EntityHandlers;
4
5
use Queryr\Replicator\Importer\EntityHandler;
6
use Queryr\TermStore\TermStoreWriter;
7
use Wikibase\DataModel\Entity\EntityDocument;
8
use Wikibase\DataModel\Term\FingerprintProvider;
9
10
/**
11
 * @licence GNU GPL v2+
12
 * @author Jeroen De Dauw < [email protected] >
13
 */
14
class TermStoreEntityHandler implements EntityHandler {
15
16
	private $tsWriter;
17
18 1
	public function __construct( TermStoreWriter $tsWriter ) {
19 1
		$this->tsWriter = $tsWriter;
20 1
	}
21
22 1
	public function handleEntity( EntityDocument $entity ) {
23 1
		if ( $entity instanceof FingerprintProvider ) {
24 1
			$this->tsWriter->storeEntityFingerprint(
25 1
				$entity->getId(),
26 1
				$entity->getFingerprint()
27
			);
28
		}
29 1
	}
30
31 1
	public function getHandlingMessage( EntityDocument $entity ): string {
32 1
		return 'Inserting into Term store';
33
	}
34
35
}