@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | * |
| 19 | 19 | * @return bool |
| 20 | 20 | */ |
| 21 | - public function canCompare( DataValue $value, DataValue $comparativeValue ); |
|
| 21 | + public function canCompare(DataValue $value, DataValue $comparativeValue); |
|
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | 24 | * Runs the comparison of two DataValues. |
@@ -28,6 +28,6 @@ discard block |
||
| 28 | 28 | * |
| 29 | 29 | * @return string One of the ComparisonResult::STATUS_... constants. |
| 30 | 30 | */ |
| 31 | - public function compare( DataValue $value, DataValue $comparativeValue ); |
|
| 31 | + public function compare(DataValue $value, DataValue $comparativeValue); |
|
| 32 | 32 | |
| 33 | 33 | } |
@@ -23,9 +23,9 @@ discard block |
||
| 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 | /** |
@@ -39,14 +39,14 @@ discard block |
||
| 39 | 39 | $extLat = $comparativeValue->getLatitude(); |
| 40 | 40 | $extLong = $comparativeValue->getLongitude(); |
| 41 | 41 | |
| 42 | - $diffLat = abs( $locLat - $extLat ); |
|
| 43 | - $diffLong = abs( $locLong - $extLong ); |
|
| 44 | - if ( ( $diffLat <= $precision ) && ( $diffLong <= $precision ) ) { |
|
| 42 | + $diffLat = abs($locLat - $extLat); |
|
| 43 | + $diffLong = abs($locLong - $extLong); |
|
| 44 | + if (($diffLat <= $precision) && ($diffLong <= $precision)) { |
|
| 45 | 45 | return ComparisonResult::STATUS_MATCH; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | $daumen = $precision; |
| 49 | - if ( ( $diffLat <= pi() * $daumen ) && ( $diffLong <= pi() * $daumen ) ) { |
|
| 49 | + if (($diffLat <= pi() * $daumen) && ($diffLong <= pi() * $daumen)) { |
|
| 50 | 50 | return ComparisonResult::STATUS_PARTIAL_MATCH; |
| 51 | 51 | } |
| 52 | 52 | |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | * @param DataValue $comparativeValue |
| 61 | 61 | * @return bool |
| 62 | 62 | */ |
| 63 | - public function canCompare( DataValue $value, DataValue $comparativeValue ) { |
|
| 63 | + public function canCompare(DataValue $value, DataValue $comparativeValue) { |
|
| 64 | 64 | return $value instanceof GlobeCoordinateValue && $comparativeValue instanceof GlobeCoordinateValue; |
| 65 | 65 | } |
| 66 | 66 | |
@@ -15,6 +15,6 @@ |
||
| 15 | 15 | * |
| 16 | 16 | * @param DumpMetaInformation $dumpMetaInformation |
| 17 | 17 | */ |
| 18 | - public function save( DumpMetaInformation $dumpMetaInformation ); |
|
| 18 | + public function save(DumpMetaInformation $dumpMetaInformation); |
|
| 19 | 19 | |
| 20 | 20 | } |
@@ -20,8 +20,8 @@ discard block |
||
| 20 | 20 | * @param array &$arr |
| 21 | 21 | * @param string $tag |
| 22 | 22 | */ |
| 23 | - protected function setIndexedTagName( array &$arr, $tag ) { |
|
| 24 | - ApiResult::setIndexedTagName( $arr, $tag ); |
|
| 23 | + protected function setIndexedTagName(array &$arr, $tag) { |
|
| 24 | + ApiResult::setIndexedTagName($arr, $tag); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | /** |
@@ -33,9 +33,9 @@ discard block |
||
| 33 | 33 | * @param string $tagName |
| 34 | 34 | * @param string $idAttribute |
| 35 | 35 | */ |
| 36 | - protected function setKeyAttributeName( array &$arr, $tagName, $idAttribute ) { |
|
| 37 | - ApiResult::setArrayType( $arr, 'kvp', $idAttribute ); |
|
| 38 | - ApiResult::setIndexedTagName( $arr, $tagName ); |
|
| 36 | + protected function setKeyAttributeName(array &$arr, $tagName, $idAttribute) { |
|
| 37 | + ApiResult::setArrayType($arr, 'kvp', $idAttribute); |
|
| 38 | + ApiResult::setIndexedTagName($arr, $tagName); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | } |
@@ -43,11 +43,11 @@ |
||
| 43 | 43 | * @param int $batchSize |
| 44 | 44 | * @param bool $quiet |
| 45 | 45 | */ |
| 46 | - public function __construct( $externalValuesFilePath, $dumpInformationFilePath, $batchSize, $quiet = false ) { |
|
| 47 | - Assert::parameterType( 'string', $externalValuesFilePath, '$externalValuesFilePath' ); |
|
| 48 | - Assert::parameterType( 'string', $dumpInformationFilePath, '$dumpInformationFilePath' ); |
|
| 49 | - Assert::parameterType( 'integer', $batchSize, '$batchSize' ); |
|
| 50 | - Assert::parameterType( 'boolean', $quiet, '$quiet' ); |
|
| 46 | + public function __construct($externalValuesFilePath, $dumpInformationFilePath, $batchSize, $quiet = false) { |
|
| 47 | + Assert::parameterType('string', $externalValuesFilePath, '$externalValuesFilePath'); |
|
| 48 | + Assert::parameterType('string', $dumpInformationFilePath, '$dumpInformationFilePath'); |
|
| 49 | + Assert::parameterType('integer', $batchSize, '$batchSize'); |
|
| 50 | + Assert::parameterType('boolean', $quiet, '$quiet'); |
|
| 51 | 51 | |
| 52 | 52 | $this->externalValuesFilePath = $externalValuesFilePath; |
| 53 | 53 | $this->dumpInformationFilePath = $dumpInformationFilePath; |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * @return DumpMetaInformation[] |
| 21 | 21 | * @throws \InvalidArgumentException |
| 22 | 22 | */ |
| 23 | - public function getWithIds( array $dumpIds ); |
|
| 23 | + public function getWithIds(array $dumpIds); |
|
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * Gets DumpMetaInformation for specific identifier properties from database |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | * |
| 31 | 31 | * @return DumpMetaInformation[] |
| 32 | 32 | */ |
| 33 | - public function getWithIdentifierProperties( array $identifierPropertyIds ); |
|
| 33 | + public function getWithIdentifierProperties(array $identifierPropertyIds); |
|
| 34 | 34 | |
| 35 | 35 | /** |
| 36 | 36 | * Gets all DumpMetaInformation from database |
@@ -7,10 +7,10 @@ discard block |
||
| 7 | 7 | use WikibaseQuality\ExternalValidation\UpdateExternalData\CsvImportSettings; |
| 8 | 8 | use WikibaseQuality\ExternalValidation\UpdateExternalData\ExternalDataImporter; |
| 9 | 9 | |
| 10 | -$basePath = getenv( 'MW_INSTALL_PATH' ) !== false |
|
| 11 | - ? getenv( 'MW_INSTALL_PATH' ) |
|
| 12 | - : __DIR__ . '/../../..'; |
|
| 13 | -require_once $basePath . '/maintenance/Maintenance.php'; |
|
| 10 | +$basePath = getenv('MW_INSTALL_PATH') !== false |
|
| 11 | + ? getenv('MW_INSTALL_PATH') |
|
| 12 | + : __DIR__.'/../../..'; |
|
| 13 | +require_once $basePath.'/maintenance/Maintenance.php'; |
|
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * Maintenance script that evokes updates of wbqev_external_data, wbqev_dump_information, wbqev_identifier_properties |
@@ -25,17 +25,17 @@ discard block |
||
| 25 | 25 | public function __construct() { |
| 26 | 26 | parent::__construct(); |
| 27 | 27 | |
| 28 | - $this->addDescription( 'Imports external entities from given CSV files into the local ' |
|
| 29 | - . 'database. CSV files can be generated using the DumpConverter.' ); |
|
| 30 | - $this->addOption( 'external-values-file', 'CSV file containing external values for import.', true, true ); |
|
| 31 | - $this->addOption( 'dump-information-file', 'CSV file containing dump meta information for import.', true, true ); |
|
| 32 | - $this->setBatchSize( 1000 ); |
|
| 28 | + $this->addDescription('Imports external entities from given CSV files into the local ' |
|
| 29 | + . 'database. CSV files can be generated using the DumpConverter.'); |
|
| 30 | + $this->addOption('external-values-file', 'CSV file containing external values for import.', true, true); |
|
| 31 | + $this->addOption('dump-information-file', 'CSV file containing dump meta information for import.', true, true); |
|
| 32 | + $this->setBatchSize(1000); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | public function execute() { |
| 36 | 36 | $context = new CsvImportSettings( |
| 37 | - $this->getOption( 'external-values-file' ), |
|
| 38 | - $this->getOption( 'dump-information-file' ), |
|
| 37 | + $this->getOption('external-values-file'), |
|
| 38 | + $this->getOption('dump-information-file'), |
|
| 39 | 39 | $this->mBatchSize, |
| 40 | 40 | $this->isQuiet() |
| 41 | 41 | ); |
@@ -23,9 +23,9 @@ discard block |
||
| 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 |
||
| 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 | } |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | * |
| 51 | 51 | * @return bool |
| 52 | 52 | */ |
| 53 | - public function canCompare( DataValue $value, DataValue $comparativeValue ) { |
|
| 53 | + public function canCompare(DataValue $value, DataValue $comparativeValue) { |
|
| 54 | 54 | return $value instanceof QuantityValue && $comparativeValue instanceof QuantityValue; |
| 55 | 55 | } |
| 56 | 56 | |
@@ -38,7 +38,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |