@@ -29,9 +29,9 @@ discard block |
||
29 | 29 | * @throws InvalidArgumentException |
30 | 30 | * @return string One of the ComparisonResult::STATUS_... constants. |
31 | 31 | */ |
32 | - public function compare( DataValue $value, DataValue $comparativeValue ) { |
|
33 | - if ( !$this->canCompare( $value, $comparativeValue ) ) { |
|
34 | - throw new InvalidArgumentException( 'Given values can not be compared using this comparer.' ); |
|
32 | + public function compare(DataValue $value, DataValue $comparativeValue) { |
|
33 | + if (!$this->canCompare($value, $comparativeValue)) { |
|
34 | + throw new InvalidArgumentException('Given values can not be compared using this comparer.'); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
@@ -41,15 +41,15 @@ discard block |
||
41 | 41 | |
42 | 42 | $result = ComparisonResult::STATUS_MISMATCH; |
43 | 43 | |
44 | - if ( !preg_match( '/^([-+]?)(\d*)((\d{4}\b).*)/', $value->getTime(), $localMatches ) |
|
45 | - || !preg_match( '/^([-+]?)(\d*)((\d{4}\b).*)/', $comparativeValue->getTime(), $externalMatches ) |
|
44 | + if (!preg_match('/^([-+]?)(\d*)((\d{4}\b).*)/', $value->getTime(), $localMatches) |
|
45 | + || !preg_match('/^([-+]?)(\d*)((\d{4}\b).*)/', $comparativeValue->getTime(), $externalMatches) |
|
46 | 46 | ) { |
47 | 47 | return ComparisonResult::STATUS_MISMATCH; |
48 | 48 | } |
49 | - list( , $localSign, $localYearHigh, $localMwTime, $localYearLow ) = $localMatches; |
|
50 | - list( , $externalSign, $externalYearHigh, $externalMwTime, $externalYearLow ) = $externalMatches; |
|
51 | - if ( $localSign !== $externalSign && ( $localYearHigh . $localYearLow !== '0000' |
|
52 | - || $externalYearHigh . $externalYearLow !== '0000' ) |
|
49 | + list(, $localSign, $localYearHigh, $localMwTime, $localYearLow) = $localMatches; |
|
50 | + list(, $externalSign, $externalYearHigh, $externalMwTime, $externalYearLow) = $externalMatches; |
|
51 | + if ($localSign !== $externalSign && ($localYearHigh.$localYearLow !== '0000' |
|
52 | + || $externalYearHigh.$externalYearLow !== '0000') |
|
53 | 53 | ) { |
54 | 54 | return ComparisonResult::STATUS_MISMATCH; |
55 | 55 | } |
@@ -58,24 +58,24 @@ discard block |
||
58 | 58 | $externalYearHigh = $externalYearHigh === '' ? 0 : (int)$externalYearHigh; |
59 | 59 | |
60 | 60 | try { |
61 | - $localTimestamp = new MWTimestamp( $localMwTime ); |
|
62 | - $externalTimestamp = new MWTimestamp( $externalMwTime ); |
|
63 | - $diff = $localTimestamp->diff( $externalTimestamp ); |
|
64 | - $diff->y += abs( $localYearHigh - $externalYearHigh ) * 10000; |
|
61 | + $localTimestamp = new MWTimestamp($localMwTime); |
|
62 | + $externalTimestamp = new MWTimestamp($externalMwTime); |
|
63 | + $diff = $localTimestamp->diff($externalTimestamp); |
|
64 | + $diff->y += abs($localYearHigh - $externalYearHigh) * 10000; |
|
65 | 65 | |
66 | - if ( $value->getPrecision() === $comparativeValue->getPrecision() |
|
67 | - && $this->resultOfDiffWithPrecision( $diff, $value->getPrecision() ) |
|
66 | + if ($value->getPrecision() === $comparativeValue->getPrecision() |
|
67 | + && $this->resultOfDiffWithPrecision($diff, $value->getPrecision()) |
|
68 | 68 | ) { |
69 | 69 | $result = ComparisonResult::STATUS_MATCH; |
70 | 70 | } elseif ( |
71 | 71 | $this->resultOfDiffWithPrecision( |
72 | 72 | $diff, |
73 | - min( $value->getPrecision(), $comparativeValue->getPrecision() ) |
|
73 | + min($value->getPrecision(), $comparativeValue->getPrecision()) |
|
74 | 74 | ) |
75 | 75 | ) { |
76 | 76 | $result = ComparisonResult::STATUS_PARTIAL_MATCH; |
77 | 77 | } |
78 | - } catch ( TimestampException $ex ) { |
|
78 | + } catch (TimestampException $ex) { |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | return $result; |
@@ -89,10 +89,10 @@ discard block |
||
89 | 89 | * |
90 | 90 | * @return bool |
91 | 91 | */ |
92 | - private function resultOfDiffWithPrecision( DateInterval $diff, $precision ) { |
|
92 | + private function resultOfDiffWithPrecision(DateInterval $diff, $precision) { |
|
93 | 93 | $result = true; |
94 | 94 | |
95 | - switch ( $precision ) { |
|
95 | + switch ($precision) { |
|
96 | 96 | case TimeValue::PRECISION_SECOND: |
97 | 97 | $result = $diff->s === 0; |
98 | 98 | // Fall through with no break/return. This is critical for this algorithm. |
@@ -136,10 +136,10 @@ discard block |
||
136 | 136 | * |
137 | 137 | * @return ValueParser |
138 | 138 | */ |
139 | - protected function getExternalValueParser( DumpMetaInformation $dumpMetaInformation ) { |
|
139 | + protected function getExternalValueParser(DumpMetaInformation $dumpMetaInformation) { |
|
140 | 140 | $parserOptions = new ParserOptions(); |
141 | - $parserOptions->setOption( ValueParser::OPT_LANG, $dumpMetaInformation->getLanguageCode() ); |
|
142 | - $timeParserFactory = new TimeParserFactory( $parserOptions ); |
|
141 | + $parserOptions->setOption(ValueParser::OPT_LANG, $dumpMetaInformation->getLanguageCode()); |
|
142 | + $timeParserFactory = new TimeParserFactory($parserOptions); |
|
143 | 143 | |
144 | 144 | return $timeParserFactory->getTimeParser(); |
145 | 145 | } |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @return bool |
154 | 154 | */ |
155 | - public function canCompare( DataValue $value, DataValue $comparativeValue ) { |
|
155 | + public function canCompare(DataValue $value, DataValue $comparativeValue) { |
|
156 | 156 | return $value instanceof TimeValue && $comparativeValue instanceof TimeValue; |
157 | 157 | } |
158 | 158 |