Completed
Push — master ( f552f8...7247aa )
by
unknown
03:16
created

FingerprintPatcher   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 5
Bugs 0 Features 1
Metric Value
wmc 2
c 5
b 0
f 1
lcom 1
cbo 4
dl 0
loc 43
ccs 19
cts 19
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A patchFingerprint() 0 16 1
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\Term\Fingerprint;
8
9
/**
10
 * TODO: Class should be public.
11
 * TODO: Should this support actual edit conflict detection?
12
 *
13
 * Package private.
14
 *
15
 * @since 1.0
16
 *
17
 * @license GPL-2.0+
18
 * @author Jeroen De Dauw < [email protected] >
19
 * @author Thiemo Mättig
20
 */
21
class FingerprintPatcher {
22
23
	/**
24
	 * @var TermListPatcher
25
	 */
26
	private $termListPatcher;
27 4
28 4
	/**
29 4
	 * @var AliasGroupListPatcher
30
	 */
31
	private $aliasGroupListPatcher;
32
33
	public function __construct() {
34
		$this->termListPatcher = new TermListPatcher();
35
		$this->aliasGroupListPatcher = new AliasGroupListPatcher();
36
	}
37 4
38 4
	/**
39 4
	 * @since 1.0
40 4
	 *
41 4
	 * @param Fingerprint $fingerprint
42
	 * @param EntityDiff $patch
43 4
	 *
44
	 * @throws PatcherException
45 4
	 */
46 4
	public function patchFingerprint( Fingerprint $fingerprint, EntityDiff $patch ) {
47 4
		$this->termListPatcher->patchTermList(
48 4
			$fingerprint->getLabels(),
49
			$patch->getLabelsDiff()
50 4
		);
51
52 4
		$this->termListPatcher->patchTermList(
53 4
			$fingerprint->getDescriptions(),
54
			$patch->getDescriptionsDiff()
55
		);
56
57
		$this->aliasGroupListPatcher->patchAliasGroupList(
58
			$fingerprint->getAliasGroups(),
59
			$patch->getAliasesDiff()
60 4
		);
61 4
	}
62
63
}
64