FingerprintPatcher::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 0
cp 0
crap 2
rs 10
1
<?php
2
3
namespace Wikibase\DataModel\Services\Diff\Internal;
4
5
use Diff\Patcher\PatcherException;
6
use Wikibase\DataModel\Services\Diff\EntityDiff;
7
use Wikibase\DataModel\Services\Diff\TermListPatcher;
8
use Wikibase\DataModel\Term\Fingerprint;
9
10
/**
11
 * Package private.
12
 *
13
 * @since 1.0
14
 *
15
 * @license GPL-2.0-or-later
16
 * @author Jeroen De Dauw < [email protected] >
17
 * @author Thiemo Kreuz
18
 */
19
class FingerprintPatcher {
20
21
	/**
22
	 * @var TermListPatcher
23
	 */
24
	private $termListPatcher;
25
26
	/**
27 4
	 * @var AliasGroupListPatcher
28 4
	 */
29 4
	private $aliasGroupListPatcher;
30
31
	public function __construct() {
32
		$this->termListPatcher = new TermListPatcher();
33
		$this->aliasGroupListPatcher = new AliasGroupListPatcher();
34
	}
35
36
	/**
37 4
	 * @since 1.0
38 4
	 *
39 4
	 * @param Fingerprint $fingerprint
40 4
	 * @param EntityDiff $patch
41 4
	 *
42
	 * @throws PatcherException
43 4
	 */
44
	public function patchFingerprint( Fingerprint $fingerprint, EntityDiff $patch ) {
45 4
		$this->termListPatcher->patchTermList(
46 4
			$fingerprint->getLabels(),
47 4
			$patch->getLabelsDiff()
48 4
		);
49
50 4
		$this->termListPatcher->patchTermList(
51
			$fingerprint->getDescriptions(),
52 4
			$patch->getDescriptionsDiff()
53 4
		);
54
55
		$this->aliasGroupListPatcher->patchAliasGroupList(
56
			$fingerprint->getAliasGroups(),
57
			$patch->getAliasesDiff()
58
		);
59
	}
60 4
61
}
62