@@ -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 |
@@ -40,16 +40,16 @@ discard block |
||
40 | 40 | $externalId, |
41 | 41 | DumpMetaInformation $dumpMetaInformation |
42 | 42 | ) { |
43 | - Assert::parameterType( 'string', $externalId, '$externalId' ); |
|
43 | + Assert::parameterType('string', $externalId, '$externalId'); |
|
44 | 44 | |
45 | - if ( count( $statement->getReferences() ) === 0 ) { |
|
45 | + if (count($statement->getReferences()) === 0) { |
|
46 | 46 | $status = ReferenceResult::STATUS_REFERENCES_MISSING; |
47 | 47 | } else { |
48 | 48 | $status = ReferenceResult::STATUS_REFERENCES_STATED; |
49 | 49 | } |
50 | 50 | |
51 | - $externalReference = $this->buildReference( $identifierPropertyId, $externalId, $dumpMetaInformation ); |
|
52 | - return new ReferenceResult( $status, $externalReference ); |
|
51 | + $externalReference = $this->buildReference($identifierPropertyId, $externalId, $dumpMetaInformation); |
|
52 | + return new ReferenceResult($status, $externalReference); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -60,17 +60,17 @@ discard block |
||
60 | 60 | * @param DumpMetaInformation $dumpMetaInformation |
61 | 61 | * @return Reference |
62 | 62 | */ |
63 | - private function buildReference( PropertyId $identifierPropertyId, $externalId, DumpMetaInformation $dumpMetaInformation ) { |
|
63 | + private function buildReference(PropertyId $identifierPropertyId, $externalId, DumpMetaInformation $dumpMetaInformation) { |
|
64 | 64 | global $wgWBQEVStatedInPID; |
65 | 65 | |
66 | 66 | $sourceItemId = $dumpMetaInformation->getSourceItemId(); |
67 | 67 | $statedInAuthoritySnak = new PropertyValueSnak( |
68 | - new PropertyId( $wgWBQEVStatedInPID ), |
|
69 | - new EntityIdValue( $sourceItemId ) |
|
68 | + new PropertyId($wgWBQEVStatedInPID), |
|
69 | + new EntityIdValue($sourceItemId) |
|
70 | 70 | ); |
71 | 71 | $authorityWithExternalIdSnak = new PropertyValueSnak( |
72 | 72 | $identifierPropertyId, |
73 | - new StringValue( $externalId ) |
|
73 | + new StringValue($externalId) |
|
74 | 74 | ); |
75 | 75 | |
76 | 76 | return new Reference( |