Completed
Push — master ( 517e4f...0d0d38 )
by
unknown
02:47
created
includes/CrossCheck/Comparer/QuantityValueComparer.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -23,9 +23,9 @@  discard block
 block discarded – undo
23 23
 	 * @throws InvalidArgumentException
24 24
 	 * @return string One of the ComparisonResult::STATUS_... constants.
25 25
 	 */
26
-	public function compare( DataValue $value, DataValue $comparativeValue ) {
27
-		if ( !$this->canCompare( $value, $comparativeValue ) ) {
28
-			throw new InvalidArgumentException( 'Given values can not be compared using this comparer.' );
26
+	public function compare(DataValue $value, DataValue $comparativeValue) {
27
+		if (!$this->canCompare($value, $comparativeValue)) {
28
+			throw new InvalidArgumentException('Given values can not be compared using this comparer.');
29 29
 		}
30 30
 
31 31
 		/**
@@ -33,8 +33,8 @@  discard block
 block discarded – undo
33 33
 		 * @var QuantityValue $comparativeValue
34 34
 		 */
35 35
 
36
-		if ( $comparativeValue->getLowerBound()->compare( $value->getUpperBound() ) <= 0 &&
37
-			$comparativeValue->getUpperBound()->compare( $value->getLowerBound() ) >= 0
36
+		if ($comparativeValue->getLowerBound()->compare($value->getUpperBound()) <= 0 &&
37
+			$comparativeValue->getUpperBound()->compare($value->getLowerBound()) >= 0
38 38
 		) {
39 39
 			return ComparisonResult::STATUS_MATCH;
40 40
 		}
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	 * @param DataValue $comparativeValue
50 50
 	 * @return bool
51 51
 	 */
52
-	public function canCompare( DataValue $value, DataValue $comparativeValue ) {
52
+	public function canCompare(DataValue $value, DataValue $comparativeValue) {
53 53
 		return $value instanceof QuantityValue && $comparativeValue instanceof QuantityValue;
54 54
 	}
55 55
 
Please login to merge, or discard this patch.
includes/CrossCheck/Comparer/StringComparer.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	/**
27 27
 	 * @param StringNormalizer $stringNormalizer
28 28
 	 */
29
-	public function __construct( StringNormalizer $stringNormalizer ) {
29
+	public function __construct(StringNormalizer $stringNormalizer) {
30 30
 		$this->stringNormalizer = $stringNormalizer;
31 31
 	}
32 32
 
@@ -37,16 +37,16 @@  discard block
 block discarded – undo
37 37
 	 * @param string $comparativeValue
38 38
 	 * @return string
39 39
 	 */
40
-	public function compare( $value, $comparativeValue ) {
41
-		Assert::parameterType( 'string', $value, '$value' );
42
-		Assert::parameterType( 'string', $comparativeValue, '$comparativeValue' );
40
+	public function compare($value, $comparativeValue) {
41
+		Assert::parameterType('string', $value, '$value');
42
+		Assert::parameterType('string', $comparativeValue, '$comparativeValue');
43 43
 
44
-		$value = $this->cleanDataString( $value );
45
-		$comparativeValue = $this->cleanDataString( $comparativeValue );
44
+		$value = $this->cleanDataString($value);
45
+		$comparativeValue = $this->cleanDataString($comparativeValue);
46 46
 
47
-		if ( $value === $comparativeValue ) {
47
+		if ($value === $comparativeValue) {
48 48
 			return ComparisonResult::STATUS_MATCH;
49
-		} elseif ( $this->checkSimilarity( $value, $comparativeValue ) ) {
49
+		} elseif ($this->checkSimilarity($value, $comparativeValue)) {
50 50
 			return ComparisonResult::STATUS_PARTIAL_MATCH;
51 51
 		} else {
52 52
 			return ComparisonResult::STATUS_MISMATCH;
@@ -60,19 +60,19 @@  discard block
 block discarded – undo
60 60
 	 * @param array $comparativeValues
61 61
 	 * @return string
62 62
 	 */
63
-	public function compareWithArray( $value, array $comparativeValues ) {
64
-		Assert::parameterType( 'string', $value, '$value' );
65
-		Assert::parameterElementType( 'string', $comparativeValues, '$comparativeValues' );
63
+	public function compareWithArray($value, array $comparativeValues) {
64
+		Assert::parameterType('string', $value, '$value');
65
+		Assert::parameterElementType('string', $comparativeValues, '$comparativeValues');
66 66
 
67
-		$value = $this->cleanDataString( $value );
68
-		$comparativeValues = $this->cleanDataArray( $comparativeValues );
67
+		$value = $this->cleanDataString($value);
68
+		$comparativeValues = $this->cleanDataArray($comparativeValues);
69 69
 
70
-		if ( in_array( $value, $comparativeValues ) ) {
70
+		if (in_array($value, $comparativeValues)) {
71 71
 			return ComparisonResult::STATUS_MATCH;
72 72
 		}
73 73
 
74
-		foreach ( $comparativeValues as $comparativeValue ) {
75
-			if ( $this->checkSimilarity( $comparativeValue, $value ) ) {
74
+		foreach ($comparativeValues as $comparativeValue) {
75
+			if ($this->checkSimilarity($comparativeValue, $value)) {
76 76
 				return ComparisonResult::STATUS_PARTIAL_MATCH;
77 77
 			}
78 78
 		}
@@ -87,11 +87,11 @@  discard block
 block discarded – undo
87 87
 	 * @param string $comparativeValue
88 88
 	 * @return bool
89 89
 	 */
90
-	private function checkSimilarity( $value, $comparativeValue ) {
90
+	private function checkSimilarity($value, $comparativeValue) {
91 91
 		return
92
-			$this->percentagePrefixSimilarity( $value, $comparativeValue ) > self::SIMILARITY_THRESHOLD ||
93
-			$this->percentageSuffixSimilarity( $value, $comparativeValue ) > self::SIMILARITY_THRESHOLD ||
94
-			$this->percentageLevenshteinDistance( $value, $comparativeValue ) > self::SIMILARITY_THRESHOLD;
92
+			$this->percentagePrefixSimilarity($value, $comparativeValue) > self::SIMILARITY_THRESHOLD ||
93
+			$this->percentageSuffixSimilarity($value, $comparativeValue) > self::SIMILARITY_THRESHOLD ||
94
+			$this->percentageLevenshteinDistance($value, $comparativeValue) > self::SIMILARITY_THRESHOLD;
95 95
 	}
96 96
 
97 97
 	/**
@@ -101,10 +101,10 @@  discard block
 block discarded – undo
101 101
 	 *
102 102
 	 * @return string
103 103
 	 */
104
-	private function cleanDataString( $value ) {
105
-		$value = $this->stringNormalizer->trimToNFC( $value );
104
+	private function cleanDataString($value) {
105
+		$value = $this->stringNormalizer->trimToNFC($value);
106 106
 
107
-		return mb_strtolower( $value );
107
+		return mb_strtolower($value);
108 108
 	}
109 109
 
110 110
 	/**
@@ -114,10 +114,10 @@  discard block
 block discarded – undo
114 114
 	 *
115 115
 	 * @return array
116 116
 	 */
117
-	private function cleanDataArray( array $array ) {
117
+	private function cleanDataArray(array $array) {
118 118
 
119 119
 		return array_map(
120
-			array( $this, 'cleanDataString' ),
120
+			array($this, 'cleanDataString'),
121 121
 			$array );
122 122
 	}
123 123
 
@@ -129,19 +129,19 @@  discard block
 block discarded – undo
129 129
 	 *
130 130
 	 * @return float
131 131
 	 */
132
-	private function percentagePrefixSimilarity( $value, $comparativeValue ) {
132
+	private function percentagePrefixSimilarity($value, $comparativeValue) {
133 133
 		$prefixLength = 0; // common prefix length
134
-		$localLength = strlen( $value );
135
-		$externalLength = strlen( $comparativeValue );
136
-		while ( $prefixLength < min( $localLength, $externalLength ) ) {
134
+		$localLength = strlen($value);
135
+		$externalLength = strlen($comparativeValue);
136
+		while ($prefixLength < min($localLength, $externalLength)) {
137 137
 			$c = $value[$prefixLength];
138
-			if ( $externalLength > $prefixLength && $comparativeValue[$prefixLength] !== $c ) {
138
+			if ($externalLength > $prefixLength && $comparativeValue[$prefixLength] !== $c) {
139 139
 				break;
140 140
 			}
141 141
 			$prefixLength++;
142 142
 		}
143 143
 
144
-		return $prefixLength / max( $localLength, $externalLength );
144
+		return $prefixLength / max($localLength, $externalLength);
145 145
 	}
146 146
 
147 147
 	/**
@@ -152,19 +152,19 @@  discard block
 block discarded – undo
152 152
 	 *
153 153
 	 * @return float
154 154
 	 */
155
-	private function percentageSuffixSimilarity( $value, $comparativeValue ) {
155
+	private function percentageSuffixSimilarity($value, $comparativeValue) {
156 156
 		$suffixLength = 0; // common suffix length
157
-		$localLength = strlen( $value );
158
-		$externalLength = strlen( $comparativeValue );
159
-		while ( $suffixLength < min( $localLength, $externalLength ) ) {
157
+		$localLength = strlen($value);
158
+		$externalLength = strlen($comparativeValue);
159
+		while ($suffixLength < min($localLength, $externalLength)) {
160 160
 			$c = $value[$localLength - 1 - $suffixLength];
161
-			if ( $externalLength > $suffixLength && $comparativeValue[$externalLength - 1 - $suffixLength] !== $c ) {
161
+			if ($externalLength > $suffixLength && $comparativeValue[$externalLength - 1 - $suffixLength] !== $c) {
162 162
 				break;
163 163
 			}
164 164
 			$suffixLength++;
165 165
 		}
166 166
 
167
-		return $suffixLength / max( $localLength, $externalLength );
167
+		return $suffixLength / max($localLength, $externalLength);
168 168
 	}
169 169
 
170 170
 	/**
@@ -175,9 +175,9 @@  discard block
 block discarded – undo
175 175
 	 *
176 176
 	 * @return float
177 177
 	 */
178
-	private function percentageLevenshteinDistance( $value, $comparativeValue ) {
179
-		$distance = levenshtein( $value, $comparativeValue );
180
-		$percentage = 1.0 - $distance / max( strlen( $value ), strlen( $comparativeValue ) );
178
+	private function percentageLevenshteinDistance($value, $comparativeValue) {
179
+		$distance = levenshtein($value, $comparativeValue);
180
+		$percentage = 1.0 - $distance / max(strlen($value), strlen($comparativeValue));
181 181
 
182 182
 		return $percentage;
183 183
 	}
Please login to merge, or discard this patch.
includes/CrossCheck/Comparer/StringValueComparer.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	/**
22 22
 	 * @param StringComparer $stringComparer
23 23
 	 */
24
-	public function __construct( StringComparer $stringComparer ) {
24
+	public function __construct(StringComparer $stringComparer) {
25 25
 		$this->stringComparer = $stringComparer;
26 26
 	}
27 27
 
@@ -34,12 +34,12 @@  discard block
 block discarded – undo
34 34
 	 * @throws InvalidArgumentException
35 35
 	 * @return string One of the ComparisonResult::STATUS_... constants.
36 36
 	 */
37
-	public function compare( DataValue $value, DataValue $comparativeValue ) {
38
-		if ( !$this->canCompare( $value, $comparativeValue ) ) {
39
-			throw new InvalidArgumentException( 'Given values can not be compared using this comparer.' );
37
+	public function compare(DataValue $value, DataValue $comparativeValue) {
38
+		if (!$this->canCompare($value, $comparativeValue)) {
39
+			throw new InvalidArgumentException('Given values can not be compared using this comparer.');
40 40
 		}
41 41
 
42
-		return $this->stringComparer->compare( $value->getValue(), $comparativeValue->getValue() );
42
+		return $this->stringComparer->compare($value->getValue(), $comparativeValue->getValue());
43 43
 	}
44 44
 
45 45
 	/**
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	 * @param DataValue $comparativeValue
50 50
 	 * @return bool
51 51
 	 */
52
-	public function canCompare( DataValue $value, DataValue $comparativeValue ) {
52
+	public function canCompare(DataValue $value, DataValue $comparativeValue) {
53 53
 		return $value instanceof StringValue && $comparativeValue instanceof StringValue;
54 54
 	}
55 55
 
Please login to merge, or discard this patch.
includes/CrossCheck/Comparer/TimeValueComparer.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -30,9 +30,9 @@  discard block
 block discarded – undo
30 30
 	 * @throws InvalidArgumentException
31 31
 	 * @return string One of the ComparisonResult::STATUS_... constants.
32 32
 	 */
33
-	public function compare( DataValue $value, DataValue $comparativeValue ) {
34
-		if ( !$this->canCompare( $value, $comparativeValue ) ) {
35
-			throw new InvalidArgumentException( 'Given values can not be compared using this comparer.' );
33
+	public function compare(DataValue $value, DataValue $comparativeValue) {
34
+		if (!$this->canCompare($value, $comparativeValue)) {
35
+			throw new InvalidArgumentException('Given values can not be compared using this comparer.');
36 36
 		}
37 37
 
38 38
 		/**
@@ -42,38 +42,38 @@  discard block
 block discarded – undo
42 42
 
43 43
 		$result = ComparisonResult::STATUS_MISMATCH;
44 44
 
45
-		if ( !preg_match( '/^([-+]?)(\d*)((\d{4}\b).*)/', $value->getTime(), $localMatches )
46
-			|| !preg_match( '/^([-+]?)(\d*)((\d{4}\b).*)/', $comparativeValue->getTime(), $externalMatches )
45
+		if (!preg_match('/^([-+]?)(\d*)((\d{4}\b).*)/', $value->getTime(), $localMatches)
46
+			|| !preg_match('/^([-+]?)(\d*)((\d{4}\b).*)/', $comparativeValue->getTime(), $externalMatches)
47 47
 		) {
48 48
 			return ComparisonResult::STATUS_MISMATCH;
49 49
 		}
50
-		list( , $localSign, $localYearHigh, $localMwTime, $localYearLow ) = $localMatches;
51
-		list( , $externalSign, $externalYearHigh, $externalMwTime, $externalYearLow ) = $externalMatches;
52
-		if ( $localSign !== $externalSign && ( $localYearHigh . $localYearLow !== '0000'
53
-				|| $externalYearHigh . $externalYearLow !== '0000' )
50
+		list(, $localSign, $localYearHigh, $localMwTime, $localYearLow) = $localMatches;
51
+		list(, $externalSign, $externalYearHigh, $externalMwTime, $externalYearLow) = $externalMatches;
52
+		if ($localSign !== $externalSign && ($localYearHigh . $localYearLow !== '0000'
53
+				|| $externalYearHigh . $externalYearLow !== '0000')
54 54
 		) {
55 55
 			return ComparisonResult::STATUS_MISMATCH;
56 56
 		}
57 57
 
58 58
 		try {
59
-			$localTimestamp = new MWTimestamp( $localMwTime );
60
-			$externalTimestamp = new MWTimestamp( $externalMwTime );
61
-			$diff = $localTimestamp->diff( $externalTimestamp );
62
-			$diff->y += abs( $localYearHigh - $externalYearHigh ) * 10000;
59
+			$localTimestamp = new MWTimestamp($localMwTime);
60
+			$externalTimestamp = new MWTimestamp($externalMwTime);
61
+			$diff = $localTimestamp->diff($externalTimestamp);
62
+			$diff->y += abs($localYearHigh - $externalYearHigh) * 10000;
63 63
 
64
-			if ( $value->getPrecision() === $comparativeValue->getPrecision()
65
-				&& $this->resultOfDiffWithPrecision( $diff, $value->getPrecision() )
64
+			if ($value->getPrecision() === $comparativeValue->getPrecision()
65
+				&& $this->resultOfDiffWithPrecision($diff, $value->getPrecision())
66 66
 			) {
67 67
 				$result = ComparisonResult::STATUS_MATCH;
68 68
 			} elseif (
69 69
 				$this->resultOfDiffWithPrecision(
70 70
 					$diff,
71
-					min( $value->getPrecision(), $comparativeValue->getPrecision() )
71
+					min($value->getPrecision(), $comparativeValue->getPrecision())
72 72
 				)
73 73
 			) {
74 74
 				$result = ComparisonResult::STATUS_PARTIAL_MATCH;
75 75
 			}
76
-		} catch ( TimestampException $ex ) {
76
+		} catch (TimestampException $ex) {
77 77
 		}
78 78
 
79 79
 		return $result;
@@ -87,10 +87,10 @@  discard block
 block discarded – undo
87 87
 	 *
88 88
 	 * @return bool
89 89
 	 */
90
-	private function resultOfDiffWithPrecision( DateInterval $diff, $precision ) {
90
+	private function resultOfDiffWithPrecision(DateInterval $diff, $precision) {
91 91
 		$result = true;
92 92
 
93
-		switch ( $precision ) {
93
+		switch ($precision) {
94 94
 			case TimeValue::PRECISION_SECOND:
95 95
 				$result = $diff->s === 0;
96 96
 				// Fall through with no break/return. This is critical for this algorithm.
@@ -134,10 +134,10 @@  discard block
 block discarded – undo
134 134
 	 *
135 135
 	 * @return ValueParser
136 136
 	 */
137
-	protected function getExternalValueParser( DumpMetaInformation $dumpMetaInformation ) {
137
+	protected function getExternalValueParser(DumpMetaInformation $dumpMetaInformation) {
138 138
 		$parserOptions = new ParserOptions();
139
-		$parserOptions->setOption( ValueParser::OPT_LANG, $dumpMetaInformation->getLanguageCode() );
140
-		$timeParserFactory = new TimeParserFactory( $parserOptions );
139
+		$parserOptions->setOption(ValueParser::OPT_LANG, $dumpMetaInformation->getLanguageCode());
140
+		$timeParserFactory = new TimeParserFactory($parserOptions);
141 141
 
142 142
 		return $timeParserFactory->getTimeParser();
143 143
 	}
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 	 *
151 151
 	 * @return bool
152 152
 	 */
153
-	public function canCompare( DataValue $value, DataValue $comparativeValue ) {
153
+	public function canCompare(DataValue $value, DataValue $comparativeValue) {
154 154
 		return $value instanceof TimeValue && $comparativeValue instanceof TimeValue;
155 155
 	}
156 156
 
Please login to merge, or discard this patch.
includes/CrossCheck/CrossChecker.php 2 patches
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -283,8 +283,7 @@  discard block
 block discarded – undo
283 283
 				$result = ComparisonResult::STATUS_MISMATCH;
284 284
 				if( in_array( ComparisonResult::STATUS_MATCH, $results ) ) {
285 285
 					$result = ComparisonResult::STATUS_MATCH;
286
-				}
287
-				elseif( in_array( ComparisonResult::STATUS_PARTIAL_MATCH, $results ) ) {
286
+				} elseif( in_array( ComparisonResult::STATUS_PARTIAL_MATCH, $results ) ) {
288 287
 					$result = ComparisonResult::STATUS_PARTIAL_MATCH;
289 288
 				}
290 289
 
@@ -314,8 +313,7 @@  discard block
 block discarded – undo
314 313
 				if( $parsedValue ) {
315 314
 					$parsedValues[] = $parsedValue;
316 315
 				}
317
-			}
318
-			catch( ParseException $e ) {}
316
+			} catch( ParseException $e ) {}
319 317
 		}
320 318
 
321 319
 		return $parsedValues;
Please login to merge, or discard this patch.
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -95,22 +95,22 @@  discard block
 block discarded – undo
95 95
 	 * @return CrossCheckResultList
96 96
 	 * @throws InvalidArgumentException
97 97
 	 */
98
-	public function crossCheckStatements( StatementList $entityStatements, StatementList $statements ) {
98
+	public function crossCheckStatements(StatementList $entityStatements, StatementList $statements) {
99 99
 		$statementsOfEntity = $entityStatements->toArray();
100 100
 
101
-		foreach ( $statements as $statement ) {
102
-			if ( !in_array( $statement, $statementsOfEntity ) ) {
103
-				throw new InvalidArgumentException( 'All statements in $statements must belong to the entity.' );
101
+		foreach ($statements as $statement) {
102
+			if (!in_array($statement, $statementsOfEntity)) {
103
+				throw new InvalidArgumentException('All statements in $statements must belong to the entity.');
104 104
 			}
105 105
 		}
106 106
 
107 107
 		$resultList = new CrossCheckResultList();
108
-		if ( $statements->count() > 0 ) {
109
-			$applicableDumps = $this->getApplicableDumps( $entityStatements );
110
-			foreach ( $applicableDumps as $identifierPropertyId => $dumpMetaInformationList ) {
111
-				$identifierPropertyId = new PropertyId( $identifierPropertyId );
108
+		if ($statements->count() > 0) {
109
+			$applicableDumps = $this->getApplicableDumps($entityStatements);
110
+			foreach ($applicableDumps as $identifierPropertyId => $dumpMetaInformationList) {
111
+				$identifierPropertyId = new PropertyId($identifierPropertyId);
112 112
 
113
-				if( $this->isIdentifierProperty( $identifierPropertyId ) ) {
113
+				if ($this->isIdentifierProperty($identifierPropertyId)) {
114 114
 					$resultList->merge(
115 115
 						$this->crossCheckStatementsWithIdentifier(
116 116
 							$entityStatements,
@@ -133,17 +133,17 @@  discard block
 block discarded – undo
133 133
 	 *
134 134
 	 * @return array[]
135 135
 	 */
136
-	private function getApplicableDumps( StatementList $statements ) {
136
+	private function getApplicableDumps(StatementList $statements) {
137 137
 		$applicableDumps = array();
138 138
 		$identifierPropertyIds = $statements->getPropertyIds();
139 139
 		$dumpMetaInformation = $this->dumpMetaInformationLookup->getWithIdentifierProperties(
140 140
 			$identifierPropertyIds
141 141
 		);
142 142
 
143
-		foreach ( $dumpMetaInformation as $dump ) {
144
-			foreach ( $dump->getIdentifierPropertyIds() as $identifierPropertyId ) {
143
+		foreach ($dumpMetaInformation as $dump) {
144
+			foreach ($dump->getIdentifierPropertyIds() as $identifierPropertyId) {
145 145
 				$serialization = $identifierPropertyId->getSerialization();
146
-				$applicableDumps[ $serialization ][ $dump->getDumpId() ] = $dump;
146
+				$applicableDumps[$serialization][$dump->getDumpId()] = $dump;
147 147
 			}
148 148
 		}
149 149
 
@@ -168,36 +168,36 @@  discard block
 block discarded – undo
168 168
 	) {
169 169
 		$resultList = new CrossCheckResultList();
170 170
 
171
-		$externalIds = $this->getExternalIds( $entityStatements, $identifierPropertyId );
172
-		if( !$externalIds ) {
171
+		$externalIds = $this->getExternalIds($entityStatements, $identifierPropertyId);
172
+		if (!$externalIds) {
173 173
 			return $resultList;
174 174
 		}
175 175
 
176 176
 		$dumpIds = array_map(
177
-			function ( DumpMetaInformation $dumpMetaInformation ) {
177
+			function(DumpMetaInformation $dumpMetaInformation) {
178 178
 				return $dumpMetaInformation->getDumpId();
179 179
 			},
180 180
 			$dumpMetaInformationList
181 181
 		);
182
-		$externalData = $this->externalDataRepo->getExternalData( $dumpIds, $externalIds, $statements->getPropertyIds() );
182
+		$externalData = $this->externalDataRepo->getExternalData($dumpIds, $externalIds, $statements->getPropertyIds());
183 183
 
184
-		foreach ( $externalData as $dumpId => $externalDataPerDump ) {
185
-			$dumpMetaInformation = $dumpMetaInformationList[ $dumpId ];
184
+		foreach ($externalData as $dumpId => $externalDataPerDump) {
185
+			$dumpMetaInformation = $dumpMetaInformationList[$dumpId];
186 186
 			$comparativeValueParser = $this->valueParserFactory->newComparativeValueParser(
187 187
 				$dumpMetaInformation->getLanguageCode()
188 188
 			);
189 189
 
190
-			foreach ( $externalDataPerDump as $externalId => $externalDataPerId ) {
190
+			foreach ($externalDataPerDump as $externalId => $externalDataPerId) {
191 191
 				$externalId = (string)$externalId;
192
-				foreach ( $externalDataPerId as $propertyId => $externalValues ) {
193
-					$propertyId = new PropertyId( $propertyId );
192
+				foreach ($externalDataPerId as $propertyId => $externalValues) {
193
+					$propertyId = new PropertyId($propertyId);
194 194
 					$resultList->merge(
195 195
 						$this->crossCheckExternalValues(
196 196
 							$dumpMetaInformation,
197 197
 							$identifierPropertyId,
198 198
 							$externalId,
199 199
 							$externalValues,
200
-							$statements->getByPropertyId( $propertyId ),
200
+							$statements->getByPropertyId($propertyId),
201 201
 							$comparativeValueParser
202 202
 						)
203 203
 					);
@@ -228,10 +228,10 @@  discard block
 block discarded – undo
228 228
 	) {
229 229
 		$resultList = new CrossCheckResultList();
230 230
 
231
-		foreach ( $statements->toArray() as $statement ) {
232
-			$comparisonResult = $this->compareStatement( $statement, $externalValues, $comparativeValueParser );
231
+		foreach ($statements->toArray() as $statement) {
232
+			$comparisonResult = $this->compareStatement($statement, $externalValues, $comparativeValueParser);
233 233
 
234
-			if ( $comparisonResult ) {
234
+			if ($comparisonResult) {
235 235
 				$referencesResult = $this->referenceHandler->checkForReferences(
236 236
 					$statement,
237 237
 					$identifierPropertyId,
@@ -265,32 +265,32 @@  discard block
 block discarded – undo
265 265
 	 * @return ComparisonResult|bool
266 266
 	 */
267 267
 	private function compareStatement(
268
-		Statement $statement,array $externalValues,
268
+		Statement $statement, array $externalValues,
269 269
 		ComparativeValueParser $comparativeValueParser
270 270
 	) {
271 271
 		$mainSnak = $statement->getMainSnak();
272
-		if ( $mainSnak instanceof PropertyValueSnak ) {
272
+		if ($mainSnak instanceof PropertyValueSnak) {
273 273
 			$dataValue = $mainSnak->getDataValue();
274 274
 
275 275
 			$results = array();
276
-			$comparativeValues = $this->parseExternalValues( $dataValue, $externalValues, $comparativeValueParser );
277
-			foreach ( $comparativeValues as $comparativeValue ) {
278
-				$result = $this->dataValueComparer->compare( $dataValue, $comparativeValue );
279
-				if( $result ) {
276
+			$comparativeValues = $this->parseExternalValues($dataValue, $externalValues, $comparativeValueParser);
277
+			foreach ($comparativeValues as $comparativeValue) {
278
+				$result = $this->dataValueComparer->compare($dataValue, $comparativeValue);
279
+				if ($result) {
280 280
 					$results[] = $result;
281 281
 				}
282 282
 			}
283 283
 
284
-			if( $results ) {
284
+			if ($results) {
285 285
 				$result = ComparisonResult::STATUS_MISMATCH;
286
-				if( in_array( ComparisonResult::STATUS_MATCH, $results ) ) {
286
+				if (in_array(ComparisonResult::STATUS_MATCH, $results)) {
287 287
 					$result = ComparisonResult::STATUS_MATCH;
288 288
 				}
289
-				elseif( in_array( ComparisonResult::STATUS_PARTIAL_MATCH, $results ) ) {
289
+				elseif (in_array(ComparisonResult::STATUS_PARTIAL_MATCH, $results)) {
290 290
 					$result = ComparisonResult::STATUS_PARTIAL_MATCH;
291 291
 				}
292 292
 
293
-				return new ComparisonResult( $dataValue, $comparativeValues, $result );
293
+				return new ComparisonResult($dataValue, $comparativeValues, $result);
294 294
 			}
295 295
 		}
296 296
 
@@ -310,14 +310,14 @@  discard block
 block discarded – undo
310 310
 		ComparativeValueParser $comparativeValueParser
311 311
 	) {
312 312
 		$parsedValues = array();
313
-		foreach ( $externalValues as $externalValue ) {
313
+		foreach ($externalValues as $externalValue) {
314 314
 			try {
315
-				$parsedValue = $comparativeValueParser->parse( $externalValue, $dataValue->getType() );
316
-				if( $parsedValue ) {
315
+				$parsedValue = $comparativeValueParser->parse($externalValue, $dataValue->getType());
316
+				if ($parsedValue) {
317 317
 					$parsedValues[] = $parsedValue;
318 318
 				}
319 319
 			}
320
-			catch( ParseException $e ) {}
320
+			catch (ParseException $e) {}
321 321
 		}
322 322
 
323 323
 		return $parsedValues;
@@ -331,12 +331,12 @@  discard block
 block discarded – undo
331 331
 	 *
332 332
 	 * @return string[]
333 333
 	 */
334
-	private function getExternalIds( StatementList $statements, PropertyId $identifierPropertyId ) {
334
+	private function getExternalIds(StatementList $statements, PropertyId $identifierPropertyId) {
335 335
 		$externalIds = array();
336
-		$identifierStatements = $statements->getByPropertyId( $identifierPropertyId );
337
-		$values = $this->getDataValues( $identifierStatements );
338
-		foreach ( $values as $value ) {
339
-			if ( $value instanceof StringValue ) {
336
+		$identifierStatements = $statements->getByPropertyId($identifierPropertyId);
337
+		$values = $this->getDataValues($identifierStatements);
338
+		foreach ($values as $value) {
339
+			if ($value instanceof StringValue) {
340 340
 				$externalIds[] = $value->getValue();
341 341
 			}
342 342
 		}
@@ -348,15 +348,15 @@  discard block
 block discarded – undo
348 348
 	 * @param PropertyId $identifierPropertyId
349 349
 	 * @return bool
350 350
 	 */
351
-	private function isIdentifierProperty( PropertyId $identifierPropertyId ) {
351
+	private function isIdentifierProperty(PropertyId $identifierPropertyId) {
352 352
 		/** @var Property $property */
353
-		$property = $this->entityLookup->getEntity( $identifierPropertyId );
354
-		$instanceOfPropertyId = new PropertyId( INSTANCE_OF_PID );
355
-		$statements = $property->getStatements()->getByPropertyId( $instanceOfPropertyId );
356
-		$values = $this->getDataValues( $statements );
357
-		foreach ( $values as $value ) {
358
-			if( $value instanceof EntityIdValue ) {
359
-				if( $value->getEntityId()->getSerialization() === IDENTIFIER_PROPERTY_QID ) {
353
+		$property = $this->entityLookup->getEntity($identifierPropertyId);
354
+		$instanceOfPropertyId = new PropertyId(INSTANCE_OF_PID);
355
+		$statements = $property->getStatements()->getByPropertyId($instanceOfPropertyId);
356
+		$values = $this->getDataValues($statements);
357
+		foreach ($values as $value) {
358
+			if ($value instanceof EntityIdValue) {
359
+				if ($value->getEntityId()->getSerialization() === IDENTIFIER_PROPERTY_QID) {
360 360
 					return true;
361 361
 				}
362 362
 			}
@@ -371,12 +371,12 @@  discard block
 block discarded – undo
371 371
 	 * @param StatementList $statementList
372 372
 	 * @return DataValue[]
373 373
 	 */
374
-	private function getDataValues( StatementList $statementList ){
374
+	private function getDataValues(StatementList $statementList) {
375 375
 		$dataValues = array();
376 376
 
377
-		foreach ( $statementList->toArray() as $statement ) {
377
+		foreach ($statementList->toArray() as $statement) {
378 378
 			$mainSnak = $statement->getMainSnak();
379
-			if ( $mainSnak instanceof PropertyValueSnak ) {
379
+			if ($mainSnak instanceof PropertyValueSnak) {
380 380
 				$dataValues[] = $mainSnak->getDataValue();
381 381
 			}
382 382
 		}
Please login to merge, or discard this patch.
includes/CrossCheck/ReferenceChecker.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -34,17 +34,17 @@  discard block
 block discarded – undo
34 34
 	 * @throws InvalidArgumentException
35 35
 	 * @return ReferenceResult
36 36
 	 */
37
-	public function checkForReferences( Statement $statement, PropertyId $identifierPropertyId, $externalId, DumpMetaInformation $dumpMetaInformation ) {
38
-		Assert::parameterType( 'string', $externalId, '$externalId' );
37
+	public function checkForReferences(Statement $statement, PropertyId $identifierPropertyId, $externalId, DumpMetaInformation $dumpMetaInformation) {
38
+		Assert::parameterType('string', $externalId, '$externalId');
39 39
 
40
-		if ( count( $statement->getReferences() ) === 0 ) {
40
+		if (count($statement->getReferences()) === 0) {
41 41
 			$status = ReferenceResult::STATUS_REFERENCES_MISSING;
42 42
 		} else {
43 43
 			$status = ReferenceResult::STATUS_REFERENCES_STATED;
44 44
 		}
45 45
 
46
-		$externalReference = $this->buildReference( $identifierPropertyId, $externalId, $dumpMetaInformation );
47
-		return new ReferenceResult( $status, $externalReference );
46
+		$externalReference = $this->buildReference($identifierPropertyId, $externalId, $dumpMetaInformation);
47
+		return new ReferenceResult($status, $externalReference);
48 48
 	}
49 49
 
50 50
 	/**
@@ -55,15 +55,15 @@  discard block
 block discarded – undo
55 55
 	 * @param DumpMetaInformation $dumpMetaInformation
56 56
 	 * @return Reference
57 57
 	 */
58
-	private function buildReference( PropertyId $identifierPropertyId, $externalId, DumpMetaInformation $dumpMetaInformation ) {
58
+	private function buildReference(PropertyId $identifierPropertyId, $externalId, DumpMetaInformation $dumpMetaInformation) {
59 59
 		$sourceItemId = $dumpMetaInformation->getSourceItemId();
60 60
 		$statedInAuthoritySnak = new PropertyValueSnak(
61
-			new PropertyId( STATED_IN_PID ),
62
-			new EntityIdValue( $sourceItemId )
61
+			new PropertyId(STATED_IN_PID),
62
+			new EntityIdValue($sourceItemId)
63 63
 		);
64 64
 		$authorityWithExternalIdSnak = new PropertyValueSnak(
65 65
 			$identifierPropertyId,
66
-			new StringValue( $externalId )
66
+			new StringValue($externalId)
67 67
 		);
68 68
 
69 69
 		return new Reference(
Please login to merge, or discard this patch.
includes/CrossCheck/Result/CrossCheckResult.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -65,14 +65,14 @@
 block discarded – undo
65 65
 	 * @param ReferenceResult $referenceResult
66 66
 	 * @throws InvalidArgumentException
67 67
 	 */
68
-	public function __construct( PropertyId $propertyId,
68
+	public function __construct(PropertyId $propertyId,
69 69
 								 $claimGuid,
70 70
 								 $externalId,
71 71
 								 DumpMetaInformation $dumpMetaInformation,
72 72
 								 ComparisonResult $comparisonResult,
73
-								 ReferenceResult $referenceResult ) {
74
-		Assert::parameterType( 'string', $claimGuid, '$claimGuid' );
75
-		Assert::parameterType( 'string', $externalId, '$externalId' );
73
+								 ReferenceResult $referenceResult) {
74
+		Assert::parameterType('string', $claimGuid, '$claimGuid');
75
+		Assert::parameterType('string', $externalId, '$externalId');
76 76
 
77 77
 		$this->propertyId = $propertyId;
78 78
 		$this->claimGuid = $claimGuid;
Please login to merge, or discard this patch.
includes/CrossCheck/Result/ReferenceResult.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -36,10 +36,10 @@  discard block
 block discarded – undo
36 36
 	 *
37 37
 	 * @throws InvalidArgumentException
38 38
 	 */
39
-	public function __construct( $status, Reference $reference ) {
39
+	public function __construct($status, Reference $reference) {
40 40
 
41 41
 		$this->reference = $reference;
42
-		$this->setStatus( $status );
42
+		$this->setStatus($status);
43 43
 	}
44 44
 
45 45
 	/**
@@ -61,14 +61,14 @@  discard block
 block discarded – undo
61 61
 	 *
62 62
 	 * @throws InvalidArgumentException
63 63
 	 */
64
-	private function setStatus( $status ) {
65
-		Assert::parameterType( 'string', $status, '$status' );
66
-		if ( !in_array(
64
+	private function setStatus($status) {
65
+		Assert::parameterType('string', $status, '$status');
66
+		if (!in_array(
67 67
 			$status,
68
-			array( self::STATUS_REFERENCES_MISSING, self::STATUS_REFERENCES_STATED )
68
+			array(self::STATUS_REFERENCES_MISSING, self::STATUS_REFERENCES_STATED)
69 69
 		)
70 70
 		) {
71
-			throw new InvalidArgumentException( '$status must be one of the status constants.' );
71
+			throw new InvalidArgumentException('$status must be one of the status constants.');
72 72
 		}
73 73
 
74 74
 		$this->status = $status;
Please login to merge, or discard this patch.
includes/CrossCheck/ValueParser/ComparativeValueParser.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 		ValueParserFactory $comparativeValueParserFactory,
39 39
 		$languageCode
40 40
 	) {
41
-		Assert::parameterType( 'string', $languageCode, '$languageCode' );
41
+		Assert::parameterType('string', $languageCode, '$languageCode');
42 42
 
43 43
 		$this->comparativeValueParserFactory = $comparativeValueParserFactory;
44 44
 		$this->languageCode = $languageCode;
@@ -52,11 +52,11 @@  discard block
 block discarded – undo
52 52
 	 *
53 53
 	 * @return DataValue
54 54
 	 */
55
-	public function parse( $value, $propertyType ) {
56
-		Assert::parameterType( 'string', $value, '$value' );
57
-		Assert::parameterType( 'string', $propertyType, '$propertyType' );
55
+	public function parse($value, $propertyType) {
56
+		Assert::parameterType('string', $value, '$value');
57
+		Assert::parameterType('string', $propertyType, '$propertyType');
58 58
 
59
-		return $this->getValueParser( $propertyType )->parse( $value );
59
+		return $this->getValueParser($propertyType)->parse($value);
60 60
 	}
61 61
 
62 62
 	/**
@@ -64,8 +64,8 @@  discard block
 block discarded – undo
64 64
 	 *
65 65
 	 * @return ValueParser
66 66
 	 */
67
-	private function getValueParser( $type ) {
68
-		if( !array_key_exists( $type, $this->valueParsers ) ) {
67
+	private function getValueParser($type) {
68
+		if (!array_key_exists($type, $this->valueParsers)) {
69 69
 			$parserOptions = $this->getParserOptions();
70 70
 			$this->valueParsers[$type] = $this->comparativeValueParserFactory->newParser(
71 71
 				$type,
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
 	 */
82 82
 	private function getParserOptions() {
83 83
 		$options = new ParserOptions();
84
-		$options->setOption( 'valuelang', $this->languageCode );
85
-		$options->setOption( ValueParser::OPT_LANG, $this->languageCode );
84
+		$options->setOption('valuelang', $this->languageCode);
85
+		$options->setOption(ValueParser::OPT_LANG, $this->languageCode);
86 86
 
87 87
 		return $options;
88 88
 	}
Please login to merge, or discard this patch.