@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * @param Serializer $dataValueSerializer |
26 | 26 | * @param Serializer $referenceSerializer |
27 | 27 | */ |
28 | - public function __construct( Serializer $dataValueSerializer, Serializer $referenceSerializer ) { |
|
28 | + public function __construct(Serializer $dataValueSerializer, Serializer $referenceSerializer) { |
|
29 | 29 | $this->dataValueSerializer = $dataValueSerializer; |
30 | 30 | $this->referenceSerializer = $referenceSerializer; |
31 | 31 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * @return Serializer |
48 | 48 | */ |
49 | 49 | public function newComparisonResultSerializer() { |
50 | - return new ComparisonResultSerializer( $this->dataValueSerializer ); |
|
50 | + return new ComparisonResultSerializer($this->dataValueSerializer); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * @return Serializer |
79 | 79 | */ |
80 | 80 | public function newReferenceResultSerializer() { |
81 | - return new ReferenceResultSerializer( $this->referenceSerializer ); |
|
81 | + return new ReferenceResultSerializer($this->referenceSerializer); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | } |
@@ -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; |
@@ -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 array( |
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(), |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @throws InvalidArgumentException |
28 | 28 | */ |
29 | - public function __construct( array $results = array() ) { |
|
30 | - Assert::parameterElementType( CrossCheckResult::class, $results, '$results' ); |
|
29 | + public function __construct(array $results = array()) { |
|
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 = array(); |
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 = array(); |
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 | } |
@@ -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 | - array( self::STATUS_MATCH, self::STATUS_PARTIAL_MATCH, self::STATUS_MISMATCH ) |
|
86 | + array(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; |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * @param TermIndex $termIndex |
33 | 33 | * @param StringComparer $stringComparer |
34 | 34 | */ |
35 | - public function __construct( TermIndex $termIndex, StringComparer $stringComparer ) { |
|
35 | + public function __construct(TermIndex $termIndex, StringComparer $stringComparer) { |
|
36 | 36 | $this->termIndex = $termIndex; |
37 | 37 | $this->stringComparer = $stringComparer; |
38 | 38 | } |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | * |
46 | 46 | * @return string|null One of the ComparisonResult::STATUS_... constants. |
47 | 47 | */ |
48 | - public function compare( DataValue $value, DataValue $comparativeValue ) { |
|
49 | - Assert::parameterType( EntityIdValue::class, $value, '$value' ); |
|
50 | - Assert::parameterType( MonolingualTextValue::class, $comparativeValue, '$comparativeValue' ); |
|
48 | + public function compare(DataValue $value, DataValue $comparativeValue) { |
|
49 | + Assert::parameterType(EntityIdValue::class, $value, '$value'); |
|
50 | + Assert::parameterType(MonolingualTextValue::class, $comparativeValue, '$comparativeValue'); |
|
51 | 51 | |
52 | 52 | /** |
53 | 53 | * @var EntityIdValue $value |
@@ -56,10 +56,10 @@ discard block |
||
56 | 56 | |
57 | 57 | $entityId = $value->getEntityId(); |
58 | 58 | $language = $comparativeValue->getLanguageCode(); |
59 | - $terms = $this->getTerms( $entityId, $language ); |
|
59 | + $terms = $this->getTerms($entityId, $language); |
|
60 | 60 | |
61 | - if ( $terms ) { |
|
62 | - return $this->stringComparer->compareWithArray( $comparativeValue->getText(), $terms ); |
|
61 | + if ($terms) { |
|
62 | + return $this->stringComparer->compareWithArray($comparativeValue->getText(), $terms); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | return null; |
@@ -73,18 +73,18 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @return array |
75 | 75 | */ |
76 | - private function getTerms( EntityId $entityId, $language ) { |
|
76 | + private function getTerms(EntityId $entityId, $language) { |
|
77 | 77 | $terms = $this->termIndex->getTermsOfEntity( |
78 | 78 | $entityId, |
79 | 79 | array( |
80 | 80 | TermIndexEntry::TYPE_LABEL, |
81 | 81 | TermIndexEntry::TYPE_ALIAS |
82 | 82 | ), |
83 | - array( $language ) |
|
83 | + array($language) |
|
84 | 84 | ); |
85 | 85 | |
86 | 86 | return array_map( |
87 | - function( TermIndexEntry $term ) { |
|
87 | + function(TermIndexEntry $term) { |
|
88 | 88 | return $term->getText(); |
89 | 89 | }, |
90 | 90 | $terms |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * @param DataValue $comparativeValue |
99 | 99 | * @return bool |
100 | 100 | */ |
101 | - public function canCompare( DataValue $value, DataValue $comparativeValue ) { |
|
101 | + public function canCompare(DataValue $value, DataValue $comparativeValue) { |
|
102 | 102 | return $value instanceof EntityIdValue && $comparativeValue instanceof MonolingualTextValue; |
103 | 103 | } |
104 | 104 |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @param StatementGuidParser $statementGuidParser |
44 | 44 | * @param CrossChecker $crossChecker |
45 | 45 | */ |
46 | - public function __construct( EntityLookup $entityLookup, StatementGuidParser $statementGuidParser, CrossChecker $crossChecker ) { |
|
46 | + public function __construct(EntityLookup $entityLookup, StatementGuidParser $statementGuidParser, CrossChecker $crossChecker) { |
|
47 | 47 | $this->entityLookup = $entityLookup; |
48 | 48 | $this->statementGuidParser = $statementGuidParser; |
49 | 49 | $this->crossChecker = $crossChecker; |
@@ -56,11 +56,11 @@ discard block |
||
56 | 56 | * |
57 | 57 | * @return CrossCheckResultList|null |
58 | 58 | */ |
59 | - public function crossCheckEntityById( EntityId $entityId ) { |
|
60 | - $entity = $this->entityLookup->getEntity( $entityId ); |
|
59 | + public function crossCheckEntityById(EntityId $entityId) { |
|
60 | + $entity = $this->entityLookup->getEntity($entityId); |
|
61 | 61 | |
62 | - if ( $entity instanceof StatementListProvider ) { |
|
63 | - return $this->crossCheckStatements( $entity->getStatements() ); |
|
62 | + if ($entity instanceof StatementListProvider) { |
|
63 | + return $this->crossCheckStatements($entity->getStatements()); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | return null; |
@@ -73,12 +73,12 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @return CrossCheckResultList[] |
75 | 75 | */ |
76 | - public function crossCheckEntitiesByIds( array $entityIds ) { |
|
77 | - Assert::parameterElementType( EntityId::class, $entityIds, '$entityIds' ); |
|
76 | + public function crossCheckEntitiesByIds(array $entityIds) { |
|
77 | + Assert::parameterElementType(EntityId::class, $entityIds, '$entityIds'); |
|
78 | 78 | |
79 | 79 | $results = array(); |
80 | - foreach ( $entityIds as $entityId ) { |
|
81 | - $results[$entityId->getSerialization()] = $this->crossCheckEntityById( $entityId ); |
|
80 | + foreach ($entityIds as $entityId) { |
|
81 | + $results[$entityId->getSerialization()] = $this->crossCheckEntityById($entityId); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | return $results; |
@@ -91,8 +91,8 @@ discard block |
||
91 | 91 | * |
92 | 92 | * @return CrossCheckResultList |
93 | 93 | */ |
94 | - public function crossCheckStatements( StatementList $statements ) { |
|
95 | - return $this->crossChecker->crossCheckStatements( $statements, $statements ); |
|
94 | + public function crossCheckStatements(StatementList $statements) { |
|
95 | + return $this->crossChecker->crossCheckStatements($statements, $statements); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -103,14 +103,14 @@ discard block |
||
103 | 103 | * @return CrossCheckResultList[] |
104 | 104 | * @throws InvalidArgumentException |
105 | 105 | */ |
106 | - public function crossCheckEntities( array $entities ) { |
|
107 | - Assert::parameterElementType( EntityDocument::class, $entities, '$entities' ); |
|
106 | + public function crossCheckEntities(array $entities) { |
|
107 | + Assert::parameterElementType(EntityDocument::class, $entities, '$entities'); |
|
108 | 108 | |
109 | 109 | $results = array(); |
110 | - foreach ( $entities as $entity ) { |
|
110 | + foreach ($entities as $entity) { |
|
111 | 111 | $entityId = $entity->getId()->getSerialization(); |
112 | - if ( $entity instanceof StatementListProvider ) { |
|
113 | - $results[$entityId] = $this->crossCheckStatements( $entity->getStatements() ); |
|
112 | + if ($entity instanceof StatementListProvider) { |
|
113 | + $results[$entityId] = $this->crossCheckStatements($entity->getStatements()); |
|
114 | 114 | } |
115 | 115 | } |
116 | 116 | |
@@ -126,13 +126,13 @@ discard block |
||
126 | 126 | * @return CrossCheckResultList|null |
127 | 127 | * @throws InvalidArgumentException |
128 | 128 | */ |
129 | - public function crossCheckEntityByIdWithProperties( EntityId $entityId, array $propertyIds ) { |
|
130 | - Assert::parameterElementType( PropertyId::class, $propertyIds, '$propertyIds' ); |
|
129 | + public function crossCheckEntityByIdWithProperties(EntityId $entityId, array $propertyIds) { |
|
130 | + Assert::parameterElementType(PropertyId::class, $propertyIds, '$propertyIds'); |
|
131 | 131 | |
132 | - $entity = $this->entityLookup->getEntity( $entityId ); |
|
132 | + $entity = $this->entityLookup->getEntity($entityId); |
|
133 | 133 | |
134 | - if ( $entity instanceof StatementListProvider ) { |
|
135 | - return $this->crossCheckStatementsWithProperties( $entity->getStatements(), $propertyIds ); |
|
134 | + if ($entity instanceof StatementListProvider) { |
|
135 | + return $this->crossCheckStatementsWithProperties($entity->getStatements(), $propertyIds); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | return null; |
@@ -147,13 +147,13 @@ discard block |
||
147 | 147 | * @return CrossCheckResultList[] |
148 | 148 | * @throws InvalidArgumentException |
149 | 149 | */ |
150 | - public function crossCheckEntitiesByIdWithProperties( array $entityIds, array $propertyIds ) { |
|
151 | - Assert::parameterElementType( EntityId::class, $entityIds, '$entityIds' ); |
|
152 | - Assert::parameterElementType( PropertyId::class, $propertyIds, '$propertyIds' ); |
|
150 | + public function crossCheckEntitiesByIdWithProperties(array $entityIds, array $propertyIds) { |
|
151 | + Assert::parameterElementType(EntityId::class, $entityIds, '$entityIds'); |
|
152 | + Assert::parameterElementType(PropertyId::class, $propertyIds, '$propertyIds'); |
|
153 | 153 | |
154 | 154 | $results = array(); |
155 | - foreach ( $entityIds as $entityId ) { |
|
156 | - $results[$entityId->getSerialization()] = $this->crossCheckEntityByIdWithProperties( $entityId, $propertyIds ); |
|
155 | + foreach ($entityIds as $entityId) { |
|
156 | + $results[$entityId->getSerialization()] = $this->crossCheckEntityByIdWithProperties($entityId, $propertyIds); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | return $results; |
@@ -168,17 +168,17 @@ discard block |
||
168 | 168 | * @return CrossCheckResultList |
169 | 169 | * @throws InvalidArgumentException |
170 | 170 | */ |
171 | - public function crossCheckStatementsWithProperties( StatementList $entityStatements, array $propertyIds ) { |
|
172 | - Assert::parameterElementType( PropertyId::class, $propertyIds, '$propertyIds' ); |
|
171 | + public function crossCheckStatementsWithProperties(StatementList $entityStatements, array $propertyIds) { |
|
172 | + Assert::parameterElementType(PropertyId::class, $propertyIds, '$propertyIds'); |
|
173 | 173 | |
174 | 174 | $statements = new StatementList(); |
175 | - foreach ( $entityStatements->toArray() as $statement ) { |
|
176 | - if ( in_array( $statement->getPropertyId(), $propertyIds ) ) { |
|
177 | - $statements->addStatement( $statement ); |
|
175 | + foreach ($entityStatements->toArray() as $statement) { |
|
176 | + if (in_array($statement->getPropertyId(), $propertyIds)) { |
|
177 | + $statements->addStatement($statement); |
|
178 | 178 | } |
179 | 179 | } |
180 | 180 | |
181 | - return $this->crossChecker->crossCheckStatements( $entityStatements, $statements ); |
|
181 | + return $this->crossChecker->crossCheckStatements($entityStatements, $statements); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
@@ -190,14 +190,14 @@ discard block |
||
190 | 190 | * @return CrossCheckResultList[] |
191 | 191 | * @throws InvalidArgumentException |
192 | 192 | */ |
193 | - public function crossCheckEntitiesWithProperties( array $entities, array $propertyIds ) { |
|
194 | - Assert::parameterElementType( EntityDocument::class, $entities, '$entities' ); |
|
195 | - Assert::parameterElementType( PropertyId::class, $propertyIds, '$propertyIds' ); |
|
193 | + public function crossCheckEntitiesWithProperties(array $entities, array $propertyIds) { |
|
194 | + Assert::parameterElementType(EntityDocument::class, $entities, '$entities'); |
|
195 | + Assert::parameterElementType(PropertyId::class, $propertyIds, '$propertyIds'); |
|
196 | 196 | |
197 | 197 | $results = array(); |
198 | - foreach ( $entities as $entity ) { |
|
198 | + foreach ($entities as $entity) { |
|
199 | 199 | $entityId = $entity->getId()->getSerialization(); |
200 | - if ( $entity instanceof StatementListProvider ) { |
|
200 | + if ($entity instanceof StatementListProvider) { |
|
201 | 201 | $results[$entityId] = $this->crossCheckStatementsWithProperties( |
202 | 202 | $entity->getStatements(), |
203 | 203 | $propertyIds |
@@ -216,12 +216,12 @@ discard block |
||
216 | 216 | * @return CrossCheckResultList |
217 | 217 | * @throws InvalidArgumentException |
218 | 218 | */ |
219 | - public function crossCheckStatementByGuid( $guid ) { |
|
220 | - $this->assertIsString( $guid, '$guid' ); |
|
219 | + public function crossCheckStatementByGuid($guid) { |
|
220 | + $this->assertIsString($guid, '$guid'); |
|
221 | 221 | |
222 | - $resultList = $this->crossCheckStatementsByGuids( array( $guid ) ); |
|
222 | + $resultList = $this->crossCheckStatementsByGuids(array($guid)); |
|
223 | 223 | |
224 | - return reset( $resultList ); |
|
224 | + return reset($resultList); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | /** |
@@ -232,21 +232,21 @@ discard block |
||
232 | 232 | * @return CrossCheckResultList[] |
233 | 233 | * @throws InvalidArgumentException |
234 | 234 | */ |
235 | - public function crossCheckStatementsByGuids( array $guids ) { |
|
236 | - $this->assertIsArrayOfStrings( $guids, '$guids' ); |
|
235 | + public function crossCheckStatementsByGuids(array $guids) { |
|
236 | + $this->assertIsArrayOfStrings($guids, '$guids'); |
|
237 | 237 | |
238 | 238 | $entityIds = array(); |
239 | 239 | $groupedStatementGuids = array(); |
240 | - foreach ( $guids as $guid ) { |
|
241 | - $serializedEntityId = $this->statementGuidParser->parse( $guid )->getEntityId(); |
|
240 | + foreach ($guids as $guid) { |
|
241 | + $serializedEntityId = $this->statementGuidParser->parse($guid)->getEntityId(); |
|
242 | 242 | $entityIds[$serializedEntityId->getSerialization()] = $serializedEntityId; |
243 | 243 | $groupedStatementGuids[$serializedEntityId->getSerialization()][] = $guid; |
244 | 244 | } |
245 | 245 | |
246 | 246 | $resultLists = array(); |
247 | - foreach ( $groupedStatementGuids as $serializedEntityId => $guidsOfEntity ) { |
|
248 | - $entityId = $entityIds[ $serializedEntityId ]; |
|
249 | - $resultLists[ $serializedEntityId ] = $this->crossCheckClaimsOfEntity( $entityId, $guidsOfEntity ); |
|
247 | + foreach ($groupedStatementGuids as $serializedEntityId => $guidsOfEntity) { |
|
248 | + $entityId = $entityIds[$serializedEntityId]; |
|
249 | + $resultLists[$serializedEntityId] = $this->crossCheckClaimsOfEntity($entityId, $guidsOfEntity); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | return $resultLists; |
@@ -258,18 +258,18 @@ discard block |
||
258 | 258 | * |
259 | 259 | * @return CrossCheckResultList|null |
260 | 260 | */ |
261 | - private function crossCheckClaimsOfEntity( EntityId $entityId, array $guids ) { |
|
262 | - $entity = $this->entityLookup->getEntity( $entityId ); |
|
261 | + private function crossCheckClaimsOfEntity(EntityId $entityId, array $guids) { |
|
262 | + $entity = $this->entityLookup->getEntity($entityId); |
|
263 | 263 | |
264 | - if ( $entity instanceof StatementListProvider ) { |
|
264 | + if ($entity instanceof StatementListProvider) { |
|
265 | 265 | $statements = new StatementList(); |
266 | - foreach ( $entity->getStatements()->toArray() as $statement ) { |
|
267 | - if ( in_array( $statement->getGuid(), $guids ) ) { |
|
268 | - $statements->addStatement( $statement ); |
|
266 | + foreach ($entity->getStatements()->toArray() as $statement) { |
|
267 | + if (in_array($statement->getGuid(), $guids)) { |
|
268 | + $statements->addStatement($statement); |
|
269 | 269 | } |
270 | 270 | } |
271 | 271 | |
272 | - return $this->crossChecker->crossCheckStatements( $entity->getStatements(), $statements ); |
|
272 | + return $this->crossChecker->crossCheckStatements($entity->getStatements(), $statements); |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | return null; |
@@ -281,9 +281,9 @@ discard block |
||
281 | 281 | * |
282 | 282 | * @throws InvalidArgumentException |
283 | 283 | */ |
284 | - private function assertIsString( $string, $parameterName ) { |
|
285 | - if ( !is_string( $string ) ) { |
|
286 | - throw new InvalidArgumentException( "$parameterName must be string." ); |
|
284 | + private function assertIsString($string, $parameterName) { |
|
285 | + if (!is_string($string)) { |
|
286 | + throw new InvalidArgumentException("$parameterName must be string."); |
|
287 | 287 | } |
288 | 288 | } |
289 | 289 | |
@@ -293,10 +293,10 @@ discard block |
||
293 | 293 | * |
294 | 294 | * @throws InvalidArgumentException |
295 | 295 | */ |
296 | - private function assertIsArrayOfStrings( array $strings, $parameterName ) { |
|
297 | - foreach ( $strings as $string ) { |
|
298 | - if ( !is_string( $string ) ) { |
|
299 | - throw new InvalidArgumentException( "Each element of $parameterName must be string." ); |
|
296 | + private function assertIsArrayOfStrings(array $strings, $parameterName) { |
|
297 | + foreach ($strings as $string) { |
|
298 | + if (!is_string($string)) { |
|
299 | + throw new InvalidArgumentException("Each element of $parameterName must be string."); |
|
300 | 300 | } |
301 | 301 | } |
302 | 302 | } |
@@ -7,16 +7,16 @@ |
||
7 | 7 | * |
8 | 8 | * @return bool |
9 | 9 | */ |
10 | - public static function onCreateSchema( DatabaseUpdater $updater ) { |
|
11 | - $updater->addExtensionTable( 'wbqev_dump_information', __DIR__ . '/sql/create_wbqev_dump_information.sql' ); |
|
12 | - $updater->addExtensionTable( 'wbqev_external_data', __DIR__ . '/sql/create_wbqev_external_data.sql' ); |
|
13 | - $updater->addExtensionTable( 'wbqev_identifier_properties', __DIR__ . '/sql/create_wbqev_identifier_properties.sql' ); |
|
10 | + public static function onCreateSchema(DatabaseUpdater $updater) { |
|
11 | + $updater->addExtensionTable('wbqev_dump_information', __DIR__.'/sql/create_wbqev_dump_information.sql'); |
|
12 | + $updater->addExtensionTable('wbqev_external_data', __DIR__.'/sql/create_wbqev_external_data.sql'); |
|
13 | + $updater->addExtensionTable('wbqev_identifier_properties', __DIR__.'/sql/create_wbqev_identifier_properties.sql'); |
|
14 | 14 | |
15 | 15 | return true; |
16 | 16 | } |
17 | 17 | |
18 | - public static function onUnitTestsList( &$paths ) { |
|
19 | - $paths[] = __DIR__ . '/tests/phpunit'; |
|
18 | + public static function onUnitTestsList(&$paths) { |
|
19 | + $paths[] = __DIR__.'/tests/phpunit'; |
|
20 | 20 | return true; |
21 | 21 | } |
22 | 22 |
@@ -30,9 +30,9 @@ discard block |
||
30 | 30 | * @throws InvalidArgumentException |
31 | 31 | * @return string One of the ComparisonResult::STATUS_... constants. |
32 | 32 | */ |
33 | - public function compare( DataValue $value, DataValue $comparativeValue ) { |
|
34 | - if ( !$this->canCompare( $value, $comparativeValue ) ) { |
|
35 | - throw new InvalidArgumentException( 'Given values can not be compared using this comparer.' ); |
|
33 | + public function compare(DataValue $value, DataValue $comparativeValue) { |
|
34 | + if (!$this->canCompare($value, $comparativeValue)) { |
|
35 | + throw new InvalidArgumentException('Given values can not be compared using this comparer.'); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
@@ -42,38 +42,38 @@ discard block |
||
42 | 42 | |
43 | 43 | $result = ComparisonResult::STATUS_MISMATCH; |
44 | 44 | |
45 | - if ( !preg_match( '/^([-+]?)(\d*)((\d{4}\b).*)/', $value->getTime(), $localMatches ) |
|
46 | - || !preg_match( '/^([-+]?)(\d*)((\d{4}\b).*)/', $comparativeValue->getTime(), $externalMatches ) |
|
45 | + if (!preg_match('/^([-+]?)(\d*)((\d{4}\b).*)/', $value->getTime(), $localMatches) |
|
46 | + || !preg_match('/^([-+]?)(\d*)((\d{4}\b).*)/', $comparativeValue->getTime(), $externalMatches) |
|
47 | 47 | ) { |
48 | 48 | return ComparisonResult::STATUS_MISMATCH; |
49 | 49 | } |
50 | - list( , $localSign, $localYearHigh, $localMwTime, $localYearLow ) = $localMatches; |
|
51 | - list( , $externalSign, $externalYearHigh, $externalMwTime, $externalYearLow ) = $externalMatches; |
|
52 | - if ( $localSign !== $externalSign && ( $localYearHigh . $localYearLow !== '0000' |
|
53 | - || $externalYearHigh . $externalYearLow !== '0000' ) |
|
50 | + list(, $localSign, $localYearHigh, $localMwTime, $localYearLow) = $localMatches; |
|
51 | + list(, $externalSign, $externalYearHigh, $externalMwTime, $externalYearLow) = $externalMatches; |
|
52 | + if ($localSign !== $externalSign && ($localYearHigh.$localYearLow !== '0000' |
|
53 | + || $externalYearHigh.$externalYearLow !== '0000') |
|
54 | 54 | ) { |
55 | 55 | return ComparisonResult::STATUS_MISMATCH; |
56 | 56 | } |
57 | 57 | |
58 | 58 | try { |
59 | - $localTimestamp = new MWTimestamp( $localMwTime ); |
|
60 | - $externalTimestamp = new MWTimestamp( $externalMwTime ); |
|
61 | - $diff = $localTimestamp->diff( $externalTimestamp ); |
|
62 | - $diff->y += abs( $localYearHigh - $externalYearHigh ) * 10000; |
|
59 | + $localTimestamp = new MWTimestamp($localMwTime); |
|
60 | + $externalTimestamp = new MWTimestamp($externalMwTime); |
|
61 | + $diff = $localTimestamp->diff($externalTimestamp); |
|
62 | + $diff->y += abs($localYearHigh - $externalYearHigh) * 10000; |
|
63 | 63 | |
64 | - if ( $value->getPrecision() === $comparativeValue->getPrecision() |
|
65 | - && $this->resultOfDiffWithPrecision( $diff, $value->getPrecision() ) |
|
64 | + if ($value->getPrecision() === $comparativeValue->getPrecision() |
|
65 | + && $this->resultOfDiffWithPrecision($diff, $value->getPrecision()) |
|
66 | 66 | ) { |
67 | 67 | $result = ComparisonResult::STATUS_MATCH; |
68 | 68 | } elseif ( |
69 | 69 | $this->resultOfDiffWithPrecision( |
70 | 70 | $diff, |
71 | - min( $value->getPrecision(), $comparativeValue->getPrecision() ) |
|
71 | + min($value->getPrecision(), $comparativeValue->getPrecision()) |
|
72 | 72 | ) |
73 | 73 | ) { |
74 | 74 | $result = ComparisonResult::STATUS_PARTIAL_MATCH; |
75 | 75 | } |
76 | - } catch ( TimestampException $ex ) { |
|
76 | + } catch (TimestampException $ex) { |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | return $result; |
@@ -87,10 +87,10 @@ discard block |
||
87 | 87 | * |
88 | 88 | * @return bool |
89 | 89 | */ |
90 | - private function resultOfDiffWithPrecision( DateInterval $diff, $precision ) { |
|
90 | + private function resultOfDiffWithPrecision(DateInterval $diff, $precision) { |
|
91 | 91 | $result = true; |
92 | 92 | |
93 | - switch ( $precision ) { |
|
93 | + switch ($precision) { |
|
94 | 94 | case TimeValue::PRECISION_SECOND: |
95 | 95 | $result = $diff->s === 0; |
96 | 96 | // Fall through with no break/return. This is critical for this algorithm. |
@@ -134,10 +134,10 @@ discard block |
||
134 | 134 | * |
135 | 135 | * @return ValueParser |
136 | 136 | */ |
137 | - protected function getExternalValueParser( DumpMetaInformation $dumpMetaInformation ) { |
|
137 | + protected function getExternalValueParser(DumpMetaInformation $dumpMetaInformation) { |
|
138 | 138 | $parserOptions = new ParserOptions(); |
139 | - $parserOptions->setOption( ValueParser::OPT_LANG, $dumpMetaInformation->getLanguageCode() ); |
|
140 | - $timeParserFactory = new TimeParserFactory( $parserOptions ); |
|
139 | + $parserOptions->setOption(ValueParser::OPT_LANG, $dumpMetaInformation->getLanguageCode()); |
|
140 | + $timeParserFactory = new TimeParserFactory($parserOptions); |
|
141 | 141 | |
142 | 142 | return $timeParserFactory->getTimeParser(); |
143 | 143 | } |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | * |
151 | 151 | * @return bool |
152 | 152 | */ |
153 | - public function canCompare( DataValue $value, DataValue $comparativeValue ) { |
|
153 | + public function canCompare(DataValue $value, DataValue $comparativeValue) { |
|
154 | 154 | return $value instanceof TimeValue && $comparativeValue instanceof TimeValue; |
155 | 155 | } |
156 | 156 |