@@ -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 | } |
@@ -10,6 +10,6 @@ |
||
10 | 10 | |
11 | 11 | /** English (English) */ |
12 | 12 | $specialPageAliases['en'] = [ |
13 | - 'CrossCheck' => [ 'CrossCheck', 'Cross Check' ], |
|
14 | - 'ExternalDatabases' => [ 'ExternalDatabases', 'ExternalDbs', 'External Dbs' ], |
|
13 | + 'CrossCheck' => ['CrossCheck', 'Cross Check'], |
|
14 | + 'ExternalDatabases' => ['ExternalDatabases', 'ExternalDbs', 'External Dbs'], |
|
15 | 15 | ]; |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @return bool |
23 | 23 | */ |
24 | - public function isSerializerFor( $object ) { |
|
24 | + public function isSerializerFor($object) { |
|
25 | 25 | return $object instanceof DumpMetaInformation; |
26 | 26 | } |
27 | 27 | |
@@ -33,32 +33,32 @@ discard block |
||
33 | 33 | * @return array |
34 | 34 | * @throws UnsupportedObjectException |
35 | 35 | */ |
36 | - public function serialize( $object ) { |
|
37 | - if ( !$this->isSerializerFor( $object ) ) { |
|
36 | + public function serialize($object) { |
|
37 | + if (!$this->isSerializerFor($object)) { |
|
38 | 38 | throw new UnsupportedObjectException( |
39 | 39 | $object, |
40 | 40 | 'DumpMetaInformationSerializer can only serialize DumpMetaInformation objects.' |
41 | 41 | ); |
42 | 42 | } |
43 | 43 | |
44 | - return $this->getSerialized( $object ); |
|
44 | + return $this->getSerialized($object); |
|
45 | 45 | } |
46 | 46 | |
47 | - private function getSerialized( DumpMetaInformation $dumpMetaInformation ) { |
|
47 | + private function getSerialized(DumpMetaInformation $dumpMetaInformation) { |
|
48 | 48 | $identifierPropertyIds = array_map( |
49 | - function( PropertyId $id ) { |
|
49 | + function(PropertyId $id) { |
|
50 | 50 | return $id->getSerialization(); |
51 | 51 | }, |
52 | 52 | $dumpMetaInformation->getIdentifierPropertyIds() |
53 | 53 | ); |
54 | 54 | |
55 | - $this->setIndexedTagName( $identifierPropertyIds, 'propertyId' ); |
|
55 | + $this->setIndexedTagName($identifierPropertyIds, 'propertyId'); |
|
56 | 56 | |
57 | 57 | return [ |
58 | 58 | 'dumpId' => $dumpMetaInformation->getDumpId(), |
59 | 59 | 'sourceItemId' => $dumpMetaInformation->getSourceItemId()->getSerialization(), |
60 | 60 | 'identifierPropertyIds' => $identifierPropertyIds, |
61 | - 'importDate' => wfTimestamp( TS_ISO_8601, $dumpMetaInformation->getImportDate() ), |
|
61 | + 'importDate' => wfTimestamp(TS_ISO_8601, $dumpMetaInformation->getImportDate()), |
|
62 | 62 | 'language' => $dumpMetaInformation->getLanguageCode(), |
63 | 63 | 'sourceUrl' => $dumpMetaInformation->getSourceUrl(), |
64 | 64 | 'size' => $dumpMetaInformation->getSize(), |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * |
52 | 52 | * @return bool |
53 | 53 | */ |
54 | - public function isSerializerFor( $object ) { |
|
54 | + public function isSerializerFor($object) { |
|
55 | 55 | return $object instanceof CrossCheckResult; |
56 | 56 | } |
57 | 57 | |
@@ -63,25 +63,25 @@ discard block |
||
63 | 63 | * @return array |
64 | 64 | * @throws UnsupportedObjectException |
65 | 65 | */ |
66 | - public function serialize( $object ) { |
|
67 | - if ( !$this->isSerializerFor( $object ) ) { |
|
66 | + public function serialize($object) { |
|
67 | + if (!$this->isSerializerFor($object)) { |
|
68 | 68 | throw new UnsupportedObjectException( |
69 | 69 | $object, |
70 | 70 | 'CrossCheckResultSerializer can only serialize CrossCheckResult objects.' |
71 | 71 | ); |
72 | 72 | } |
73 | 73 | |
74 | - return $this->getSerialized( $object ); |
|
74 | + return $this->getSerialized($object); |
|
75 | 75 | } |
76 | 76 | |
77 | - private function getSerialized( CrossCheckResult $crossCheckResult ) { |
|
77 | + private function getSerialized(CrossCheckResult $crossCheckResult) { |
|
78 | 78 | return [ |
79 | 79 | 'propertyId' => $crossCheckResult->getPropertyId()->getSerialization(), |
80 | 80 | 'claimGuid' => $crossCheckResult->getClaimGuid(), |
81 | 81 | 'externalId' => $crossCheckResult->getExternalId(), |
82 | - 'dataSource' => $this->dumpMetaInformationSerializer->serialize( $crossCheckResult->getDumpMetaInformation() ), |
|
83 | - 'comparisonResult' => $this->comparisonResultSerializer->serialize( $crossCheckResult->getComparisonResult() ), |
|
84 | - 'referenceResult' => $this->referenceResultSerializer->serialize( $crossCheckResult->getReferenceResult() ) |
|
82 | + 'dataSource' => $this->dumpMetaInformationSerializer->serialize($crossCheckResult->getDumpMetaInformation()), |
|
83 | + 'comparisonResult' => $this->comparisonResultSerializer->serialize($crossCheckResult->getComparisonResult()), |
|
84 | + 'referenceResult' => $this->referenceResultSerializer->serialize($crossCheckResult->getReferenceResult()) |
|
85 | 85 | ]; |
86 | 86 | } |
87 | 87 |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | ) { |
44 | 44 | $dataTypeIds = $dataTypeDefinitions->getTypeIds(); |
45 | 45 | |
46 | - if ( !in_array( 'monolingualtext', $dataTypeIds ) ) { |
|
46 | + if (!in_array('monolingualtext', $dataTypeIds)) { |
|
47 | 47 | throw new InvalidArgumentException( |
48 | 48 | 'monolingualtext must be defined in the DataTypeDefinitions.' |
49 | 49 | ); |
@@ -58,21 +58,21 @@ discard block |
||
58 | 58 | * |
59 | 59 | * @return MultilingualTextValueParser |
60 | 60 | */ |
61 | - public function newMultilingualTextValueParser( ParserOptions $options = null ) { |
|
61 | + public function newMultilingualTextValueParser(ParserOptions $options = null) { |
|
62 | 62 | $options = $options ?: new ParserOptions(); |
63 | 63 | $monolingualTextValueParser = $this->getValueParserFactory()->newParser( |
64 | 64 | 'monolingualtext', |
65 | 65 | $options |
66 | 66 | ); |
67 | 67 | |
68 | - return new MultilingualTextValueParser( $monolingualTextValueParser ); |
|
68 | + return new MultilingualTextValueParser($monolingualTextValueParser); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
72 | 72 | * @return StringValueParser |
73 | 73 | */ |
74 | 74 | public function newStringValueParser() { |
75 | - return new StringValueParser( $this->stringNormalizer ); |
|
75 | + return new StringValueParser($this->stringNormalizer); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @return ComparativeValueParser |
82 | 82 | */ |
83 | - public function newComparativeValueParser( $languageCode ) { |
|
84 | - Assert::parameterType( 'string', $languageCode, '$languageCode' ); |
|
83 | + public function newComparativeValueParser($languageCode) { |
|
84 | + Assert::parameterType('string', $languageCode, '$languageCode'); |
|
85 | 85 | |
86 | 86 | return new ComparativeValueParser( |
87 | 87 | $this->getValueParserFactory(), |
@@ -100,14 +100,14 @@ discard block |
||
100 | 100 | * @return ValueParserFactory |
101 | 101 | */ |
102 | 102 | private function getValueParserFactory() { |
103 | - if ( $this->valueParserFactory === null ) { |
|
103 | + if ($this->valueParserFactory === null) { |
|
104 | 104 | $callbacks = $this->dataTypeDefinitions->getParserFactoryCallbacks(); |
105 | 105 | |
106 | - $callbacks['string'] = [ $this, 'newStringValueParser' ]; |
|
107 | - $callbacks['multilingualtext'] = [ $this, 'newMultilingualTextValueParser' ]; |
|
106 | + $callbacks['string'] = [$this, 'newStringValueParser']; |
|
107 | + $callbacks['multilingualtext'] = [$this, 'newMultilingualTextValueParser']; |
|
108 | 108 | $callbacks['wikibase-entityid'] = $callbacks['monolingualtext']; |
109 | 109 | |
110 | - $this->valueParserFactory = new ValueParserFactory( $callbacks ); |
|
110 | + $this->valueParserFactory = new ValueParserFactory($callbacks); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | return $this->valueParserFactory; |
@@ -45,12 +45,12 @@ discard block |
||
45 | 45 | * |
46 | 46 | * @throws InvalidArgumentException |
47 | 47 | */ |
48 | - public function __construct( DataValue $localValue, array $externalValues, $status ) { |
|
49 | - Assert::parameterElementType( DataValue::class, $externalValues, '$externalValues' ); |
|
48 | + public function __construct(DataValue $localValue, array $externalValues, $status) { |
|
49 | + Assert::parameterElementType(DataValue::class, $externalValues, '$externalValues'); |
|
50 | 50 | |
51 | 51 | $this->localValue = $localValue; |
52 | 52 | $this->externalValues = $externalValues; |
53 | - $this->setStatus( $status ); |
|
53 | + $this->setStatus($status); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -79,14 +79,14 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @throws InvalidArgumentException |
81 | 81 | */ |
82 | - private function setStatus( $status ) { |
|
83 | - Assert::parameterType( 'string', $status, '$status' ); |
|
84 | - if ( !in_array( |
|
82 | + private function setStatus($status) { |
|
83 | + Assert::parameterType('string', $status, '$status'); |
|
84 | + if (!in_array( |
|
85 | 85 | $status, |
86 | - [ self::STATUS_MATCH, self::STATUS_PARTIAL_MATCH, self::STATUS_MISMATCH ] |
|
86 | + [self::STATUS_MATCH, self::STATUS_PARTIAL_MATCH, self::STATUS_MISMATCH] |
|
87 | 87 | ) |
88 | 88 | ) { |
89 | - throw new InvalidArgumentException( '$status must be one of the status constants.' ); |
|
89 | + throw new InvalidArgumentException('$status must be one of the status constants.'); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | $this->status = $status; |
@@ -36,10 +36,10 @@ discard block |
||
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 |
||
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 | - [ self::STATUS_REFERENCES_MISSING, self::STATUS_REFERENCES_STATED ] |
|
68 | + [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; |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @throws InvalidArgumentException |
28 | 28 | */ |
29 | - public function __construct( array $results = [] ) { |
|
30 | - Assert::parameterElementType( CrossCheckResult::class, $results, '$results' ); |
|
29 | + public function __construct(array $results = []) { |
|
30 | + Assert::parameterElementType(CrossCheckResult::class, $results, '$results'); |
|
31 | 31 | |
32 | 32 | $this->results = $results; |
33 | 33 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * |
38 | 38 | * @param CrossCheckResult $result |
39 | 39 | */ |
40 | - public function add( CrossCheckResult $result ) { |
|
40 | + public function add(CrossCheckResult $result) { |
|
41 | 41 | $this->results[] = $result; |
42 | 42 | } |
43 | 43 | |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @param self $resultList |
48 | 48 | */ |
49 | - public function merge( self $resultList ) { |
|
50 | - $this->results = array_merge( $this->results, $resultList->results ); |
|
49 | + public function merge(self $resultList) { |
|
50 | + $this->results = array_merge($this->results, $resultList->results); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
@@ -58,9 +58,9 @@ discard block |
||
58 | 58 | public function getPropertyIds() { |
59 | 59 | $propertyIds = []; |
60 | 60 | |
61 | - foreach ( $this->results as $result ) { |
|
61 | + foreach ($this->results as $result) { |
|
62 | 62 | $propertyId = $result->getPropertyId(); |
63 | - if ( !in_array( $propertyId, $propertyIds ) ) { |
|
63 | + if (!in_array($propertyId, $propertyIds)) { |
|
64 | 64 | $propertyIds[] = $propertyId; |
65 | 65 | } |
66 | 66 | } |
@@ -75,16 +75,16 @@ discard block |
||
75 | 75 | * |
76 | 76 | * @return self |
77 | 77 | */ |
78 | - public function getByPropertyId( PropertyId $propertyId ) { |
|
78 | + public function getByPropertyId(PropertyId $propertyId) { |
|
79 | 79 | $results = []; |
80 | 80 | |
81 | - foreach ( $this->results as $result ) { |
|
82 | - if ( $result->getPropertyId()->equals( $propertyId ) ) { |
|
81 | + foreach ($this->results as $result) { |
|
82 | + if ($result->getPropertyId()->equals($propertyId)) { |
|
83 | 83 | $results[] = $result; |
84 | 84 | } |
85 | 85 | } |
86 | 86 | |
87 | - return new self( $results ); |
|
87 | + return new self($results); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * @codeCoverageIgnore |
104 | 104 | */ |
105 | 105 | public function getIterator() { |
106 | - return new ArrayIterator( $this->results ); |
|
106 | + return new ArrayIterator($this->results); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | * @return int |
113 | 113 | */ |
114 | 114 | public function count() { |
115 | - return count( $this->results ); |
|
115 | + return count($this->results); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | } |
@@ -20,8 +20,8 @@ discard block |
||
20 | 20 | /** |
21 | 21 | * @param DataValueComparer[] $dataValueComparers |
22 | 22 | */ |
23 | - public function __construct( array $dataValueComparers = [] ) { |
|
24 | - $this->assertAreDataValueComparer( $dataValueComparers ); |
|
23 | + public function __construct(array $dataValueComparers = []) { |
|
24 | + $this->assertAreDataValueComparer($dataValueComparers); |
|
25 | 25 | $this->dataValueComparers = $dataValueComparers; |
26 | 26 | } |
27 | 27 | |
@@ -30,9 +30,9 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @throws InvalidArgumentException |
32 | 32 | */ |
33 | - protected function assertAreDataValueComparer( array $dataValueComparers ) { |
|
34 | - foreach ( $dataValueComparers as $dataValueComparer ) { |
|
35 | - if ( !is_object( $dataValueComparer ) || !( $dataValueComparer instanceof DataValueComparer ) ) { |
|
33 | + protected function assertAreDataValueComparer(array $dataValueComparers) { |
|
34 | + foreach ($dataValueComparers as $dataValueComparer) { |
|
35 | + if (!is_object($dataValueComparer) || !($dataValueComparer instanceof DataValueComparer)) { |
|
36 | 36 | throw new InvalidArgumentException( |
37 | 37 | 'All $dataValueComparers need to implement the DataValueComparer interface' |
38 | 38 | ); |
@@ -48,9 +48,9 @@ discard block |
||
48 | 48 | * |
49 | 49 | * @return bool |
50 | 50 | */ |
51 | - public function canCompare( DataValue $value, DataValue $comparativeValue ) { |
|
52 | - foreach ( $this->dataValueComparers as $dataValueComparer ) { |
|
53 | - if ( $dataValueComparer->canCompare( $value, $comparativeValue ) ) { |
|
51 | + public function canCompare(DataValue $value, DataValue $comparativeValue) { |
|
52 | + foreach ($this->dataValueComparers as $dataValueComparer) { |
|
53 | + if ($dataValueComparer->canCompare($value, $comparativeValue)) { |
|
54 | 54 | return true; |
55 | 55 | } |
56 | 56 | } |
@@ -67,10 +67,10 @@ discard block |
||
67 | 67 | * @throws InvalidArgumentException |
68 | 68 | * @return string One of the ComparisonResult::STATUS_... constants. |
69 | 69 | */ |
70 | - public function compare( DataValue $value, DataValue $comparativeValue ) { |
|
71 | - foreach ( $this->dataValueComparers as $dataValueComparer ) { |
|
72 | - if ( $dataValueComparer->canCompare( $value, $comparativeValue ) ) { |
|
73 | - return $dataValueComparer->compare( $value, $comparativeValue ); |
|
70 | + public function compare(DataValue $value, DataValue $comparativeValue) { |
|
71 | + foreach ($this->dataValueComparers as $dataValueComparer) { |
|
72 | + if ($dataValueComparer->canCompare($value, $comparativeValue)) { |
|
73 | + return $dataValueComparer->compare($value, $comparativeValue); |
|
74 | 74 | } |
75 | 75 | } |
76 | 76 |