@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | private $stringNormalizer; |
| 24 | 24 | |
| 25 | - public function __construct( StringNormalizer $stringNormalizer ) { |
|
| 25 | + public function __construct(StringNormalizer $stringNormalizer) { |
|
| 26 | 26 | $this->stringNormalizer = $stringNormalizer; |
| 27 | 27 | } |
| 28 | 28 | |
@@ -33,16 +33,16 @@ discard block |
||
| 33 | 33 | * @param string $comparativeValue |
| 34 | 34 | * @return string |
| 35 | 35 | */ |
| 36 | - public function compare( $value, $comparativeValue ) { |
|
| 37 | - Assert::parameterType( 'string', $value, '$value' ); |
|
| 38 | - Assert::parameterType( 'string', $comparativeValue, '$comparativeValue' ); |
|
| 36 | + public function compare($value, $comparativeValue) { |
|
| 37 | + Assert::parameterType('string', $value, '$value'); |
|
| 38 | + Assert::parameterType('string', $comparativeValue, '$comparativeValue'); |
|
| 39 | 39 | |
| 40 | - $value = $this->cleanDataString( $value ); |
|
| 41 | - $comparativeValue = $this->cleanDataString( $comparativeValue ); |
|
| 40 | + $value = $this->cleanDataString($value); |
|
| 41 | + $comparativeValue = $this->cleanDataString($comparativeValue); |
|
| 42 | 42 | |
| 43 | - if ( $value === $comparativeValue ) { |
|
| 43 | + if ($value === $comparativeValue) { |
|
| 44 | 44 | return ComparisonResult::STATUS_MATCH; |
| 45 | - } elseif ( $this->checkSimilarity( $value, $comparativeValue ) ) { |
|
| 45 | + } elseif ($this->checkSimilarity($value, $comparativeValue)) { |
|
| 46 | 46 | return ComparisonResult::STATUS_PARTIAL_MATCH; |
| 47 | 47 | } else { |
| 48 | 48 | return ComparisonResult::STATUS_MISMATCH; |
@@ -56,19 +56,19 @@ discard block |
||
| 56 | 56 | * @param array $comparativeValues |
| 57 | 57 | * @return string |
| 58 | 58 | */ |
| 59 | - public function compareWithArray( $value, array $comparativeValues ) { |
|
| 60 | - Assert::parameterType( 'string', $value, '$value' ); |
|
| 61 | - Assert::parameterElementType( 'string', $comparativeValues, '$comparativeValues' ); |
|
| 59 | + public function compareWithArray($value, array $comparativeValues) { |
|
| 60 | + Assert::parameterType('string', $value, '$value'); |
|
| 61 | + Assert::parameterElementType('string', $comparativeValues, '$comparativeValues'); |
|
| 62 | 62 | |
| 63 | - $value = $this->cleanDataString( $value ); |
|
| 64 | - $comparativeValues = $this->cleanDataArray( $comparativeValues ); |
|
| 63 | + $value = $this->cleanDataString($value); |
|
| 64 | + $comparativeValues = $this->cleanDataArray($comparativeValues); |
|
| 65 | 65 | |
| 66 | - if ( in_array( $value, $comparativeValues ) ) { |
|
| 66 | + if (in_array($value, $comparativeValues)) { |
|
| 67 | 67 | return ComparisonResult::STATUS_MATCH; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - foreach ( $comparativeValues as $comparativeValue ) { |
|
| 71 | - if ( $this->checkSimilarity( $comparativeValue, $value ) ) { |
|
| 70 | + foreach ($comparativeValues as $comparativeValue) { |
|
| 71 | + if ($this->checkSimilarity($comparativeValue, $value)) { |
|
| 72 | 72 | return ComparisonResult::STATUS_PARTIAL_MATCH; |
| 73 | 73 | } |
| 74 | 74 | } |
@@ -83,10 +83,10 @@ discard block |
||
| 83 | 83 | * @param string $comparativeValue |
| 84 | 84 | * @return bool |
| 85 | 85 | */ |
| 86 | - private function checkSimilarity( $value, $comparativeValue ) { |
|
| 87 | - return $this->percentagePrefixSimilarity( $value, $comparativeValue ) > self::SIMILARITY_THRESHOLD |
|
| 88 | - || $this->percentageSuffixSimilarity( $value, $comparativeValue ) > self::SIMILARITY_THRESHOLD |
|
| 89 | - || $this->percentageLevenshteinDistance( $value, $comparativeValue ) > self::SIMILARITY_THRESHOLD; |
|
| 86 | + private function checkSimilarity($value, $comparativeValue) { |
|
| 87 | + return $this->percentagePrefixSimilarity($value, $comparativeValue) > self::SIMILARITY_THRESHOLD |
|
| 88 | + || $this->percentageSuffixSimilarity($value, $comparativeValue) > self::SIMILARITY_THRESHOLD |
|
| 89 | + || $this->percentageLevenshteinDistance($value, $comparativeValue) > self::SIMILARITY_THRESHOLD; |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | /** |
@@ -96,10 +96,10 @@ discard block |
||
| 96 | 96 | * |
| 97 | 97 | * @return string |
| 98 | 98 | */ |
| 99 | - private function cleanDataString( $value ) { |
|
| 100 | - $value = $this->stringNormalizer->trimToNFC( $value ); |
|
| 99 | + private function cleanDataString($value) { |
|
| 100 | + $value = $this->stringNormalizer->trimToNFC($value); |
|
| 101 | 101 | |
| 102 | - return mb_strtolower( $value ); |
|
| 102 | + return mb_strtolower($value); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
@@ -109,10 +109,10 @@ discard block |
||
| 109 | 109 | * |
| 110 | 110 | * @return array |
| 111 | 111 | */ |
| 112 | - private function cleanDataArray( array $array ) { |
|
| 112 | + private function cleanDataArray(array $array) { |
|
| 113 | 113 | |
| 114 | 114 | return array_map( |
| 115 | - [ $this, 'cleanDataString' ], |
|
| 115 | + [$this, 'cleanDataString'], |
|
| 116 | 116 | $array ); |
| 117 | 117 | } |
| 118 | 118 | |
@@ -124,19 +124,19 @@ discard block |
||
| 124 | 124 | * |
| 125 | 125 | * @return float |
| 126 | 126 | */ |
| 127 | - private function percentagePrefixSimilarity( $value, $comparativeValue ) { |
|
| 127 | + private function percentagePrefixSimilarity($value, $comparativeValue) { |
|
| 128 | 128 | $prefixLength = 0; // common prefix length |
| 129 | - $localLength = strlen( $value ); |
|
| 130 | - $externalLength = strlen( $comparativeValue ); |
|
| 131 | - while ( $prefixLength < min( $localLength, $externalLength ) ) { |
|
| 129 | + $localLength = strlen($value); |
|
| 130 | + $externalLength = strlen($comparativeValue); |
|
| 131 | + while ($prefixLength < min($localLength, $externalLength)) { |
|
| 132 | 132 | $c = $value[$prefixLength]; |
| 133 | - if ( $externalLength > $prefixLength && $comparativeValue[$prefixLength] !== $c ) { |
|
| 133 | + if ($externalLength > $prefixLength && $comparativeValue[$prefixLength] !== $c) { |
|
| 134 | 134 | break; |
| 135 | 135 | } |
| 136 | 136 | $prefixLength++; |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - return $prefixLength / max( $localLength, $externalLength ); |
|
| 139 | + return $prefixLength / max($localLength, $externalLength); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | /** |
@@ -147,19 +147,19 @@ discard block |
||
| 147 | 147 | * |
| 148 | 148 | * @return float |
| 149 | 149 | */ |
| 150 | - private function percentageSuffixSimilarity( $value, $comparativeValue ) { |
|
| 150 | + private function percentageSuffixSimilarity($value, $comparativeValue) { |
|
| 151 | 151 | $suffixLength = 0; // common suffix length |
| 152 | - $localLength = strlen( $value ); |
|
| 153 | - $externalLength = strlen( $comparativeValue ); |
|
| 154 | - while ( $suffixLength < min( $localLength, $externalLength ) ) { |
|
| 152 | + $localLength = strlen($value); |
|
| 153 | + $externalLength = strlen($comparativeValue); |
|
| 154 | + while ($suffixLength < min($localLength, $externalLength)) { |
|
| 155 | 155 | $c = $value[$localLength - 1 - $suffixLength]; |
| 156 | - if ( $externalLength > $suffixLength && $comparativeValue[$externalLength - 1 - $suffixLength] !== $c ) { |
|
| 156 | + if ($externalLength > $suffixLength && $comparativeValue[$externalLength - 1 - $suffixLength] !== $c) { |
|
| 157 | 157 | break; |
| 158 | 158 | } |
| 159 | 159 | $suffixLength++; |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - return $suffixLength / max( $localLength, $externalLength ); |
|
| 162 | + return $suffixLength / max($localLength, $externalLength); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | /** |
@@ -170,9 +170,9 @@ discard block |
||
| 170 | 170 | * |
| 171 | 171 | * @return float |
| 172 | 172 | */ |
| 173 | - private function percentageLevenshteinDistance( $value, $comparativeValue ) { |
|
| 174 | - $distance = levenshtein( $value, $comparativeValue ); |
|
| 175 | - $percentage = 1.0 - $distance / max( strlen( $value ), strlen( $comparativeValue ) ); |
|
| 173 | + private function percentageLevenshteinDistance($value, $comparativeValue) { |
|
| 174 | + $distance = levenshtein($value, $comparativeValue); |
|
| 175 | + $percentage = 1.0 - $distance / max(strlen($value), strlen($comparativeValue)); |
|
| 176 | 176 | |
| 177 | 177 | return $percentage; |
| 178 | 178 | } |
@@ -172,7 +172,7 @@ |
||
| 172 | 172 | /** |
| 173 | 173 | * Writes output for CrossCheckResultList |
| 174 | 174 | * |
| 175 | - * @param array $resultLists |
|
| 175 | + * @param \WikibaseQuality\ExternalValidation\CrossCheck\Result\CrossCheckResultList[] $resultLists |
|
| 176 | 176 | */ |
| 177 | 177 | private function writeResultOutput( array $resultLists ) { |
| 178 | 178 | $serializer = $this->serializerFactory->newCrossCheckResultListSerializer(); |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | * |
| 65 | 65 | * @return self |
| 66 | 66 | */ |
| 67 | - public static function newFromGlobalState( ApiMain $main, $name, $prefix = '' ) { |
|
| 67 | + public static function newFromGlobalState(ApiMain $main, $name, $prefix = '') { |
|
| 68 | 68 | $repo = WikibaseRepo::getDefaultInstance(); |
| 69 | 69 | $externalValidationServices = ExternalValidationServices::getDefaultInstance(); |
| 70 | 70 | |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | $repo->getStatementGuidValidator(), |
| 77 | 77 | $externalValidationServices->getCrossCheckInteractor(), |
| 78 | 78 | $externalValidationServices->getSerializerFactory(), |
| 79 | - $repo->getApiHelperFactory( RequestContext::getMain() ) |
|
| 79 | + $repo->getApiHelperFactory(RequestContext::getMain()) |
|
| 80 | 80 | ); |
| 81 | 81 | } |
| 82 | 82 | |
@@ -100,14 +100,14 @@ discard block |
||
| 100 | 100 | SerializerFactory $serializerFactory, |
| 101 | 101 | ApiHelperFactory $apiHelperFactory |
| 102 | 102 | ) { |
| 103 | - parent::__construct( $main, $name, $prefix ); |
|
| 103 | + parent::__construct($main, $name, $prefix); |
|
| 104 | 104 | |
| 105 | 105 | $this->entityIdParser = $entityIdParser; |
| 106 | 106 | $this->statementGuidValidator = $statementGuidValidator; |
| 107 | 107 | $this->crossCheckInteractor = $crossCheckInteractor; |
| 108 | 108 | $this->serializerFactory = $serializerFactory; |
| 109 | - $this->resultBuilder = $apiHelperFactory->getResultBuilder( $this ); |
|
| 110 | - $this->errorReporter = $apiHelperFactory->getErrorReporter( $this ); |
|
| 109 | + $this->resultBuilder = $apiHelperFactory->getResultBuilder($this); |
|
| 110 | + $this->errorReporter = $apiHelperFactory->getErrorReporter($this); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | /** |
@@ -116,34 +116,34 @@ discard block |
||
| 116 | 116 | public function execute() { |
| 117 | 117 | $params = $this->extractRequestParams(); |
| 118 | 118 | |
| 119 | - if ( $params['entities'] && $params['claims'] ) { |
|
| 119 | + if ($params['entities'] && $params['claims']) { |
|
| 120 | 120 | $this->errorReporter->dieError( |
| 121 | 121 | 'Either provide the ids of entities or ids of claims, that should be cross-checked.', |
| 122 | 122 | 'param-invalid' |
| 123 | 123 | ); |
| 124 | 124 | throw new LogicException(); |
| 125 | - } elseif ( $params['entities'] ) { |
|
| 126 | - $entityIds = $this->parseEntityIds( $params['entities'] ); |
|
| 127 | - if ( $params['properties'] ) { |
|
| 128 | - $propertyIds = $this->parseEntityIds( $params['properties'] ); |
|
| 129 | - $resultLists = $this->crossCheckInteractor->crossCheckEntitiesByIdWithProperties( $entityIds, $propertyIds ); |
|
| 125 | + } elseif ($params['entities']) { |
|
| 126 | + $entityIds = $this->parseEntityIds($params['entities']); |
|
| 127 | + if ($params['properties']) { |
|
| 128 | + $propertyIds = $this->parseEntityIds($params['properties']); |
|
| 129 | + $resultLists = $this->crossCheckInteractor->crossCheckEntitiesByIdWithProperties($entityIds, $propertyIds); |
|
| 130 | 130 | } else { |
| 131 | - $resultLists = $this->crossCheckInteractor->crossCheckEntitiesByIds( $entityIds ); |
|
| 131 | + $resultLists = $this->crossCheckInteractor->crossCheckEntitiesByIds($entityIds); |
|
| 132 | 132 | } |
| 133 | - } elseif ( $params['claims'] ) { |
|
| 133 | + } elseif ($params['claims']) { |
|
| 134 | 134 | $guids = $params['claims']; |
| 135 | - $this->assertAreValidClaimGuids( $guids ); |
|
| 136 | - $resultLists = $this->crossCheckInteractor->crossCheckStatementsByGuids( $guids ); |
|
| 135 | + $this->assertAreValidClaimGuids($guids); |
|
| 136 | + $resultLists = $this->crossCheckInteractor->crossCheckStatementsByGuids($guids); |
|
| 137 | 137 | } else { |
| 138 | 138 | $this->errorReporter->dieWithError( |
| 139 | - [ 'wikibase-api-param-missing', 'entities|claims' ], |
|
| 139 | + ['wikibase-api-param-missing', 'entities|claims'], |
|
| 140 | 140 | 'param-missing' |
| 141 | 141 | ); |
| 142 | 142 | throw new LogicException(); |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | // Print result lists |
| 146 | - $this->writeResultOutput( $resultLists ); |
|
| 146 | + $this->writeResultOutput($resultLists); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | /** |
@@ -151,9 +151,9 @@ discard block |
||
| 151 | 151 | * |
| 152 | 152 | * @return EntityId[] |
| 153 | 153 | */ |
| 154 | - private function parseEntityIds( array $entityIds ) { |
|
| 154 | + private function parseEntityIds(array $entityIds) { |
|
| 155 | 155 | return array_map( |
| 156 | - [ $this->entityIdParser, 'parse' ], |
|
| 156 | + [$this->entityIdParser, 'parse'], |
|
| 157 | 157 | $entityIds |
| 158 | 158 | ); |
| 159 | 159 | } |
@@ -161,10 +161,10 @@ discard block |
||
| 161 | 161 | /** |
| 162 | 162 | * @param string[] $guids |
| 163 | 163 | */ |
| 164 | - private function assertAreValidClaimGuids( array $guids ) { |
|
| 165 | - foreach ( $guids as $guid ) { |
|
| 166 | - if ( $this->statementGuidValidator->validateFormat( $guid ) === false ) { |
|
| 167 | - $this->errorReporter->dieError( 'Invalid claim guid.', 'invalid-guid' ); |
|
| 164 | + private function assertAreValidClaimGuids(array $guids) { |
|
| 165 | + foreach ($guids as $guid) { |
|
| 166 | + if ($this->statementGuidValidator->validateFormat($guid) === false) { |
|
| 167 | + $this->errorReporter->dieError('Invalid claim guid.', 'invalid-guid'); |
|
| 168 | 168 | } |
| 169 | 169 | } |
| 170 | 170 | } |
@@ -174,13 +174,13 @@ discard block |
||
| 174 | 174 | * |
| 175 | 175 | * @param array $resultLists |
| 176 | 176 | */ |
| 177 | - private function writeResultOutput( array $resultLists ) { |
|
| 177 | + private function writeResultOutput(array $resultLists) { |
|
| 178 | 178 | $serializer = $this->serializerFactory->newCrossCheckResultListSerializer(); |
| 179 | 179 | |
| 180 | 180 | $output = []; |
| 181 | - foreach ( $resultLists as $entityId => $resultList ) { |
|
| 182 | - if ( $resultList ) { |
|
| 183 | - $serializedResultList = $serializer->serialize( $resultList ); |
|
| 181 | + foreach ($resultLists as $entityId => $resultList) { |
|
| 182 | + if ($resultList) { |
|
| 183 | + $serializedResultList = $serializer->serialize($resultList); |
|
| 184 | 184 | |
| 185 | 185 | $output[$entityId] = $serializedResultList; |
| 186 | 186 | } else { |
@@ -190,10 +190,10 @@ discard block |
||
| 190 | 190 | } |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | - $this->getResult()->setIndexedTagName( $output, 'entity' ); |
|
| 194 | - $this->getResult()->setArrayType( $output, 'kvp', 'id' ); |
|
| 195 | - $this->getResult()->addValue( null, 'results', $output ); |
|
| 196 | - $this->resultBuilder->markSuccess( 1 ); |
|
| 193 | + $this->getResult()->setIndexedTagName($output, 'entity'); |
|
| 194 | + $this->getResult()->setArrayType($output, 'kvp', 'id'); |
|
| 195 | + $this->getResult()->addValue(null, 'results', $output); |
|
| 196 | + $this->resultBuilder->markSuccess(1); |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | /** |
@@ -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 | |
@@ -1,11 +1,11 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if ( function_exists( 'wfLoadExtension' ) ) { |
|
| 4 | - wfLoadExtension( 'WikibaseQualityExternalValidation', __DIR__ . '/extension.json' ); |
|
| 3 | +if (function_exists('wfLoadExtension')) { |
|
| 4 | + wfLoadExtension('WikibaseQualityExternalValidation', __DIR__.'/extension.json'); |
|
| 5 | 5 | // Keep i18n globals so mergeMessageFileList.php doesn't break |
| 6 | - $GLOBALS['wgMessagesDirs']['WikibaseQualityExternalValidation'] = __DIR__ . '/i18n'; |
|
| 6 | + $GLOBALS['wgMessagesDirs']['WikibaseQualityExternalValidation'] = __DIR__.'/i18n'; |
|
| 7 | 7 | $GLOBALS['wgExtensionMessagesFiles']['WikibaseQualityExternalValidationAlias'] = |
| 8 | - __DIR__ . '/WikibaseQualityExternalValidation.alias.php'; |
|
| 8 | + __DIR__.'/WikibaseQualityExternalValidation.alias.php'; |
|
| 9 | 9 | /* wfWarn( |
| 10 | 10 | 'Deprecated PHP entry point used for WikibaseQualityConstraints extension. ' . |
| 11 | 11 | 'Please use wfLoadExtension instead, ' . |
@@ -13,5 +13,5 @@ discard block |
||
| 13 | 13 | ); */ |
| 14 | 14 | return; |
| 15 | 15 | } else { |
| 16 | - die( 'This version of the WikibaseQualityExternalValidation extension requires MediaWiki 1.25+' ); |
|
| 16 | + die('This version of the WikibaseQualityExternalValidation extension requires MediaWiki 1.25+'); |
|
| 17 | 17 | } |