@@ -162,7 +162,7 @@ |
||
162 | 162 | /** |
163 | 163 | * Writes output for CrossCheckResultList |
164 | 164 | * |
165 | - * @param array $resultLists |
|
165 | + * @param \WikibaseQuality\ExternalValidation\CrossCheck\Result\CrossCheckResultList[] $resultLists |
|
166 | 166 | * |
167 | 167 | * @return array |
168 | 168 | */ |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @param string $prefix |
64 | 64 | * @return RunCrossCheck |
65 | 65 | */ |
66 | - public static function newFromGlobalState( ApiMain $main, $name, $prefix = '' ) { |
|
66 | + public static function newFromGlobalState(ApiMain $main, $name, $prefix = '') { |
|
67 | 67 | $repo = WikibaseRepo::getDefaultInstance(); |
68 | 68 | $externalValidationServices = ExternalValidationServices::getDefaultInstance(); |
69 | 69 | |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | $repo->getStatementGuidValidator(), |
76 | 76 | $externalValidationServices->getCrossCheckInteractor(), |
77 | 77 | $externalValidationServices->getSerializerFactory(), |
78 | - $repo->getApiHelperFactory( RequestContext::getMain() ) |
|
78 | + $repo->getApiHelperFactory(RequestContext::getMain()) |
|
79 | 79 | ); |
80 | 80 | } |
81 | 81 | |
@@ -89,17 +89,17 @@ discard block |
||
89 | 89 | * @param SerializerFactory $serializerFactory |
90 | 90 | * @param ApiHelperFactory $apiHelperFactory |
91 | 91 | */ |
92 | - public function __construct( ApiMain $main, $name, $prefix = '', EntityIdParser $entityIdParser, |
|
92 | + public function __construct(ApiMain $main, $name, $prefix = '', EntityIdParser $entityIdParser, |
|
93 | 93 | StatementGuidValidator $statementGuidValidator, CrossCheckInteractor $crossCheckInteractor, |
94 | - SerializerFactory $serializerFactory, ApiHelperFactory $apiHelperFactory ) { |
|
95 | - parent::__construct( $main, $name, $prefix ); |
|
94 | + SerializerFactory $serializerFactory, ApiHelperFactory $apiHelperFactory) { |
|
95 | + parent::__construct($main, $name, $prefix); |
|
96 | 96 | |
97 | 97 | $this->entityIdParser = $entityIdParser; |
98 | 98 | $this->statementGuidValidator = $statementGuidValidator; |
99 | 99 | $this->crossCheckInteractor = $crossCheckInteractor; |
100 | 100 | $this->serializerFactory = $serializerFactory; |
101 | - $this->resultBuilder = $apiHelperFactory->getResultBuilder( $this ); |
|
102 | - $this->errorReporter = $apiHelperFactory->getErrorReporter( $this ); |
|
101 | + $this->resultBuilder = $apiHelperFactory->getResultBuilder($this); |
|
102 | + $this->errorReporter = $apiHelperFactory->getErrorReporter($this); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
@@ -108,23 +108,23 @@ discard block |
||
108 | 108 | public function execute() { |
109 | 109 | $params = $this->extractRequestParams(); |
110 | 110 | |
111 | - if ( $params['entities'] && $params['claims'] ) { |
|
111 | + if ($params['entities'] && $params['claims']) { |
|
112 | 112 | $this->errorReporter->dieError( |
113 | 113 | 'Either provide the ids of entities or ids of claims, that should be cross-checked.', |
114 | 114 | 'param-invalid' |
115 | 115 | ); |
116 | - } elseif ( $params['entities'] ) { |
|
117 | - $entityIds = $this->parseEntityIds( $params['entities'] ); |
|
118 | - if ( $params['properties'] ) { |
|
119 | - $propertyIds = $this->parseEntityIds( $params['properties'] ); |
|
120 | - $resultLists = $this->crossCheckInteractor->crossCheckEntitiesByIdWithProperties( $entityIds, $propertyIds ); |
|
116 | + } elseif ($params['entities']) { |
|
117 | + $entityIds = $this->parseEntityIds($params['entities']); |
|
118 | + if ($params['properties']) { |
|
119 | + $propertyIds = $this->parseEntityIds($params['properties']); |
|
120 | + $resultLists = $this->crossCheckInteractor->crossCheckEntitiesByIdWithProperties($entityIds, $propertyIds); |
|
121 | 121 | } else { |
122 | - $resultLists = $this->crossCheckInteractor->crossCheckEntitiesByIds( $entityIds ); |
|
122 | + $resultLists = $this->crossCheckInteractor->crossCheckEntitiesByIds($entityIds); |
|
123 | 123 | } |
124 | - } elseif ( $params['claims'] ) { |
|
124 | + } elseif ($params['claims']) { |
|
125 | 125 | $guids = $params['claims']; |
126 | - $this->assertAreValidClaimGuids( $guids ); |
|
127 | - $resultLists = $this->crossCheckInteractor->crossCheckStatementsByGuids( $guids ); |
|
126 | + $this->assertAreValidClaimGuids($guids); |
|
127 | + $resultLists = $this->crossCheckInteractor->crossCheckStatementsByGuids($guids); |
|
128 | 128 | } else { |
129 | 129 | $this->errorReporter->dieError( |
130 | 130 | 'Either provide the ids of entities or ids of claims, that should be cross-checked.', |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | } |
134 | 134 | |
135 | 135 | // Print result lists |
136 | - $this->writeResultOutput( $resultLists ); |
|
136 | + $this->writeResultOutput($resultLists); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -141,9 +141,9 @@ discard block |
||
141 | 141 | * |
142 | 142 | * @return EntityId[] |
143 | 143 | */ |
144 | - private function parseEntityIds( array $entityIds ) { |
|
144 | + private function parseEntityIds(array $entityIds) { |
|
145 | 145 | return array_map( |
146 | - array( $this->entityIdParser, 'parse' ), |
|
146 | + array($this->entityIdParser, 'parse'), |
|
147 | 147 | $entityIds |
148 | 148 | ); |
149 | 149 | } |
@@ -151,10 +151,10 @@ discard block |
||
151 | 151 | /** |
152 | 152 | * @param string[] $guids |
153 | 153 | */ |
154 | - private function assertAreValidClaimGuids( array $guids ) { |
|
155 | - foreach ( $guids as $guid ) { |
|
156 | - if ( $this->statementGuidValidator->validateFormat( $guid ) === false ) { |
|
157 | - $this->errorReporter->dieError( 'Invalid claim guid.', 'invalid-guid' ); |
|
154 | + private function assertAreValidClaimGuids(array $guids) { |
|
155 | + foreach ($guids as $guid) { |
|
156 | + if ($this->statementGuidValidator->validateFormat($guid) === false) { |
|
157 | + $this->errorReporter->dieError('Invalid claim guid.', 'invalid-guid'); |
|
158 | 158 | } |
159 | 159 | } |
160 | 160 | } |
@@ -166,13 +166,13 @@ discard block |
||
166 | 166 | * |
167 | 167 | * @return array |
168 | 168 | */ |
169 | - private function writeResultOutput( array $resultLists ) { |
|
169 | + private function writeResultOutput(array $resultLists) { |
|
170 | 170 | $serializer = $this->serializerFactory->newCrossCheckResultListSerializer(); |
171 | 171 | |
172 | 172 | $output = array(); |
173 | - foreach ( $resultLists as $entityId => $resultList ) { |
|
174 | - if ( $resultList ) { |
|
175 | - $serializedResultList = $serializer->serialize( $resultList ); |
|
173 | + foreach ($resultLists as $entityId => $resultList) { |
|
174 | + if ($resultList) { |
|
175 | + $serializedResultList = $serializer->serialize($resultList); |
|
176 | 176 | |
177 | 177 | $output[$entityId] = $serializedResultList; |
178 | 178 | } else { |
@@ -182,10 +182,10 @@ discard block |
||
182 | 182 | } |
183 | 183 | } |
184 | 184 | |
185 | - $this->getResult()->setIndexedTagName( $output, 'entity' ); |
|
186 | - $this->getResult()->setArrayType( $output, 'kvp', 'id' ); |
|
187 | - $this->getResult()->addValue( null, 'results', $output ); |
|
188 | - $this->resultBuilder->markSuccess( 1 ); |
|
185 | + $this->getResult()->setIndexedTagName($output, 'entity'); |
|
186 | + $this->getResult()->setArrayType($output, 'kvp', 'id'); |
|
187 | + $this->getResult()->addValue(null, 'results', $output); |
|
188 | + $this->resultBuilder->markSuccess(1); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
@@ -288,7 +288,7 @@ |
||
288 | 288 | } |
289 | 289 | |
290 | 290 | /** |
291 | - * @param array $strings |
|
291 | + * @param string[] $strings |
|
292 | 292 | * @param string $parameterName |
293 | 293 | * |
294 | 294 | * @throws InvalidArgumentException |
@@ -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( 'Wikibase\DataModel\Entity\EntityId', $entityIds, '$entityIds' ); |
|
76 | + public function crossCheckEntitiesByIds(array $entityIds) { |
|
77 | + Assert::parameterElementType('Wikibase\DataModel\Entity\EntityId', $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( 'Wikibase\DataModel\Entity\Entity', $entities, '$entities' ); |
|
106 | + public function crossCheckEntities(array $entities) { |
|
107 | + Assert::parameterElementType('Wikibase\DataModel\Entity\Entity', $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( 'Wikibase\DataModel\Entity\PropertyId', $propertyIds, '$propertyIds' ); |
|
129 | + public function crossCheckEntityByIdWithProperties(EntityId $entityId, array $propertyIds) { |
|
130 | + Assert::parameterElementType('Wikibase\DataModel\Entity\PropertyId', $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( 'Wikibase\DataModel\Entity\EntityId', $entityIds, '$entityIds' ); |
|
152 | - Assert::parameterElementType( 'Wikibase\DataModel\Entity\PropertyId', $propertyIds, '$propertyIds' ); |
|
150 | + public function crossCheckEntitiesByIdWithProperties(array $entityIds, array $propertyIds) { |
|
151 | + Assert::parameterElementType('Wikibase\DataModel\Entity\EntityId', $entityIds, '$entityIds'); |
|
152 | + Assert::parameterElementType('Wikibase\DataModel\Entity\PropertyId', $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( 'Wikibase\DataModel\Entity\PropertyId', $propertyIds, '$propertyIds' ); |
|
171 | + public function crossCheckStatementsWithProperties(StatementList $entityStatements, array $propertyIds) { |
|
172 | + Assert::parameterElementType('Wikibase\DataModel\Entity\PropertyId', $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( 'Wikibase\DataModel\Entity\Entity', $entities, '$entities' ); |
|
195 | - Assert::parameterElementType( 'Wikibase\DataModel\Entity\PropertyId', $propertyIds, '$propertyIds' ); |
|
193 | + public function crossCheckEntitiesWithProperties(array $entities, array $propertyIds) { |
|
194 | + Assert::parameterElementType('Wikibase\DataModel\Entity\Entity', $entities, '$entities'); |
|
195 | + Assert::parameterElementType('Wikibase\DataModel\Entity\PropertyId', $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 | } |
@@ -201,7 +201,7 @@ |
||
201 | 201 | /** |
202 | 202 | * @param EntityDocument $entity |
203 | 203 | * |
204 | - * @return CrossCheckResultList|null |
|
204 | + * @return \WikibaseQuality\ExternalValidation\CrossCheck\Result\CrossCheckResultList|null |
|
205 | 205 | */ |
206 | 206 | private function getCrossCheckResultsFromEntity( EntityDocument $entity ) { |
207 | 207 | if ( $entity instanceof StatementListProvider ) { |
@@ -102,18 +102,18 @@ discard block |
||
102 | 102 | OutputFormatValueFormatterFactory $valueFormatterFactory, |
103 | 103 | CrossCheckInteractor $crossCheckInteractor |
104 | 104 | ) { |
105 | - parent::__construct( 'CrossCheck' ); |
|
105 | + parent::__construct('CrossCheck'); |
|
106 | 106 | |
107 | 107 | $this->entityLookup = $entityLookup; |
108 | 108 | $this->entityIdParser = $entityIdParser; |
109 | 109 | |
110 | 110 | $formatterOptions = new FormatterOptions(); |
111 | - $formatterOptions->setOption( SnakFormatter::OPT_LANG, $this->getLanguage()->getCode() ); |
|
112 | - $this->dataValueFormatter = $valueFormatterFactory->getValueFormatter( SnakFormatter::FORMAT_HTML, $formatterOptions ); |
|
111 | + $formatterOptions->setOption(SnakFormatter::OPT_LANG, $this->getLanguage()->getCode()); |
|
112 | + $this->dataValueFormatter = $valueFormatterFactory->getValueFormatter(SnakFormatter::FORMAT_HTML, $formatterOptions); |
|
113 | 113 | |
114 | - $labelLookup = new LanguageLabelDescriptionLookup( $termLookup, $this->getLanguage()->getCode() ); |
|
115 | - $this->entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter( $labelLookup ); |
|
116 | - $this->entityIdLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter( $labelLookup ); |
|
114 | + $labelLookup = new LanguageLabelDescriptionLookup($termLookup, $this->getLanguage()->getCode()); |
|
115 | + $this->entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter($labelLookup); |
|
116 | + $this->entityIdLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter($labelLookup); |
|
117 | 117 | |
118 | 118 | $this->crossCheckInteractor = $crossCheckInteractor; |
119 | 119 | } |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | * @return string (plain text) |
134 | 134 | */ |
135 | 135 | public function getDescription() { |
136 | - return $this->msg( 'wbqev-crosscheck' )->text(); |
|
136 | + return $this->msg('wbqev-crosscheck')->text(); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -145,55 +145,55 @@ discard block |
||
145 | 145 | * @throws EntityIdParsingException |
146 | 146 | * @throws UnexpectedValueException |
147 | 147 | */ |
148 | - public function execute( $subPage ) { |
|
148 | + public function execute($subPage) { |
|
149 | 149 | $out = $this->getOutput(); |
150 | - $postRequest = $this->getContext()->getRequest()->getVal( 'entityid' ); |
|
151 | - if ( $postRequest ) { |
|
152 | - $out->redirect( $this->getPageTitle( strtoupper( $postRequest ) )->getLocalURL() ); |
|
150 | + $postRequest = $this->getContext()->getRequest()->getVal('entityid'); |
|
151 | + if ($postRequest) { |
|
152 | + $out->redirect($this->getPageTitle(strtoupper($postRequest))->getLocalURL()); |
|
153 | 153 | return; |
154 | 154 | } |
155 | 155 | |
156 | - $out->addModules( 'SpecialCrossCheckPage' ); |
|
156 | + $out->addModules('SpecialCrossCheckPage'); |
|
157 | 157 | |
158 | 158 | $this->setHeaders(); |
159 | 159 | |
160 | - $out->addHTML( $this->buildInfoBox() ); |
|
160 | + $out->addHTML($this->buildInfoBox()); |
|
161 | 161 | $this->buildEntityIdForm(); |
162 | 162 | |
163 | - if ( $subPage ) { |
|
164 | - $this->buildResult( $subPage ); |
|
163 | + if ($subPage) { |
|
164 | + $this->buildResult($subPage); |
|
165 | 165 | } |
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
169 | 169 | * @param string $idSerialization |
170 | 170 | */ |
171 | - private function buildResult( $idSerialization ) { |
|
171 | + private function buildResult($idSerialization) { |
|
172 | 172 | $out = $this->getOutput(); |
173 | 173 | |
174 | 174 | try { |
175 | - $entityId = $this->entityIdParser->parse( $idSerialization ); |
|
176 | - } catch ( EntityIdParsingException $ex ) { |
|
177 | - $out->addHTML( $this->buildNotice( 'wbqev-crosscheck-invalid-entity-id', true ) ); |
|
175 | + $entityId = $this->entityIdParser->parse($idSerialization); |
|
176 | + } catch (EntityIdParsingException $ex) { |
|
177 | + $out->addHTML($this->buildNotice('wbqev-crosscheck-invalid-entity-id', true)); |
|
178 | 178 | return; |
179 | 179 | } |
180 | 180 | |
181 | - $out->addHTML( $this->buildResultHeader( $entityId ) ); |
|
181 | + $out->addHTML($this->buildResultHeader($entityId)); |
|
182 | 182 | |
183 | - $entity = $this->entityLookup->getEntity( $entityId ); |
|
184 | - if ( $entity === null ) { |
|
185 | - $out->addHTML( $this->buildNotice( 'wbqev-crosscheck-not-existent-entity', true ) ); |
|
183 | + $entity = $this->entityLookup->getEntity($entityId); |
|
184 | + if ($entity === null) { |
|
185 | + $out->addHTML($this->buildNotice('wbqev-crosscheck-not-existent-entity', true)); |
|
186 | 186 | return; |
187 | 187 | } |
188 | 188 | |
189 | - $results = $this->getCrossCheckResultsFromEntity( $entity ); |
|
189 | + $results = $this->getCrossCheckResultsFromEntity($entity); |
|
190 | 190 | |
191 | - if ( $results === null || $results->toArray() === array() ) { |
|
192 | - $out->addHTML( $this->buildNotice( 'wbqev-crosscheck-empty-result' ) ); |
|
191 | + if ($results === null || $results->toArray() === array()) { |
|
192 | + $out->addHTML($this->buildNotice('wbqev-crosscheck-empty-result')); |
|
193 | 193 | } else { |
194 | 194 | $out->addHTML( |
195 | - $this->buildSummary( $results ) |
|
196 | - . $this->buildResultTable( $results ) |
|
195 | + $this->buildSummary($results) |
|
196 | + . $this->buildResultTable($results) |
|
197 | 197 | ); |
198 | 198 | } |
199 | 199 | } |
@@ -203,9 +203,9 @@ discard block |
||
203 | 203 | * |
204 | 204 | * @return CrossCheckResultList|null |
205 | 205 | */ |
206 | - private function getCrossCheckResultsFromEntity( EntityDocument $entity ) { |
|
207 | - if ( $entity instanceof StatementListProvider ) { |
|
208 | - return $this->crossCheckInteractor->crossCheckStatements( $entity->getStatements() ); |
|
206 | + private function getCrossCheckResultsFromEntity(EntityDocument $entity) { |
|
207 | + if ($entity instanceof StatementListProvider) { |
|
208 | + return $this->crossCheckInteractor->crossCheckStatements($entity->getStatements()); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | return null; |
@@ -222,15 +222,15 @@ discard block |
||
222 | 222 | 'name' => 'entityid', |
223 | 223 | 'label-message' => 'wbqev-crosscheck-form-entityid-label', |
224 | 224 | 'cssclass' => 'wbqev-crosscheck-form-entity-id', |
225 | - 'placeholder' => $this->msg( 'wbqev-crosscheck-form-entityid-placeholder' )->escaped() |
|
225 | + 'placeholder' => $this->msg('wbqev-crosscheck-form-entityid-placeholder')->escaped() |
|
226 | 226 | ) |
227 | 227 | ); |
228 | - $htmlForm = new HTMLForm( $formDescriptor, $this->getContext(), 'wbqev-crosscheck-form' ); |
|
229 | - $htmlForm->setSubmitText( $this->msg( 'wbqev-crosscheck-form-submit-label' )->escaped() ); |
|
230 | - $htmlForm->setSubmitCallback( function() { |
|
228 | + $htmlForm = new HTMLForm($formDescriptor, $this->getContext(), 'wbqev-crosscheck-form'); |
|
229 | + $htmlForm->setSubmitText($this->msg('wbqev-crosscheck-form-submit-label')->escaped()); |
|
230 | + $htmlForm->setSubmitCallback(function() { |
|
231 | 231 | return false; |
232 | 232 | } ); |
233 | - $htmlForm->setMethod( 'post' ); |
|
233 | + $htmlForm->setMethod('post'); |
|
234 | 234 | $htmlForm->show(); |
235 | 235 | } |
236 | 236 | |
@@ -240,18 +240,18 @@ discard block |
||
240 | 240 | * @return string HTML |
241 | 241 | */ |
242 | 242 | private function buildInfoBox() { |
243 | - $externalDbLink = Linker::specialLink( 'ExternalDbs', 'wbqev-externaldbs' ); |
|
243 | + $externalDbLink = Linker::specialLink('ExternalDbs', 'wbqev-externaldbs'); |
|
244 | 244 | $infoBox = |
245 | 245 | Html::openElement( |
246 | 246 | 'div', |
247 | - array( 'class' => 'wbqev-infobox' ) |
|
247 | + array('class' => 'wbqev-infobox') |
|
248 | 248 | ) |
249 | - . $this->msg( 'wbqev-crosscheck-explanation-general' )->parse() |
|
250 | - . sprintf( ' %s.', $externalDbLink ) |
|
251 | - . Html::element( 'br' ) |
|
252 | - . Html::element( 'br' ) |
|
253 | - . $this->msg( 'wbqev-crosscheck-explanation-detail' )->parse() |
|
254 | - . Html::closeElement( 'div' ); |
|
249 | + . $this->msg('wbqev-crosscheck-explanation-general')->parse() |
|
250 | + . sprintf(' %s.', $externalDbLink) |
|
251 | + . Html::element('br') |
|
252 | + . Html::element('br') |
|
253 | + . $this->msg('wbqev-crosscheck-explanation-detail')->parse() |
|
254 | + . Html::closeElement('div'); |
|
255 | 255 | |
256 | 256 | return $infoBox; |
257 | 257 | } |
@@ -266,17 +266,17 @@ discard block |
||
266 | 266 | * |
267 | 267 | * @return string HTML |
268 | 268 | */ |
269 | - private function buildNotice( $messageKey, $error = false ) { |
|
269 | + private function buildNotice($messageKey, $error = false) { |
|
270 | 270 | $cssClasses = 'wbqev-crosscheck-notice'; |
271 | - if ( $error ) { |
|
271 | + if ($error) { |
|
272 | 272 | $cssClasses .= ' wbqev-crosscheck-notice-error'; |
273 | 273 | } |
274 | 274 | |
275 | 275 | return |
276 | 276 | Html::element( |
277 | 277 | 'p', |
278 | - array( 'class' => $cssClasses ), |
|
279 | - $this->msg( $messageKey )->text() |
|
278 | + array('class' => $cssClasses), |
|
279 | + $this->msg($messageKey)->text() |
|
280 | 280 | ); |
281 | 281 | } |
282 | 282 | |
@@ -287,18 +287,18 @@ discard block |
||
287 | 287 | * |
288 | 288 | * @return string HTML |
289 | 289 | */ |
290 | - private function buildResultHeader( EntityId $entityId ) { |
|
290 | + private function buildResultHeader(EntityId $entityId) { |
|
291 | 291 | $entityLink = sprintf( |
292 | 292 | '%s (%s)', |
293 | - $this->entityIdLinkFormatter->formatEntityId( $entityId ), |
|
294 | - htmlspecialchars( $entityId->getSerialization() ) |
|
293 | + $this->entityIdLinkFormatter->formatEntityId($entityId), |
|
294 | + htmlspecialchars($entityId->getSerialization()) |
|
295 | 295 | ); |
296 | 296 | |
297 | 297 | return |
298 | 298 | Html::rawElement( |
299 | 299 | 'h3', |
300 | 300 | array(), |
301 | - sprintf( '%s %s', $this->msg( 'wbqev-crosscheck-result-headline' )->escaped(), $entityLink ) |
|
301 | + sprintf('%s %s', $this->msg('wbqev-crosscheck-result-headline')->escaped(), $entityLink) |
|
302 | 302 | ); |
303 | 303 | } |
304 | 304 | |
@@ -309,11 +309,11 @@ discard block |
||
309 | 309 | * |
310 | 310 | * @return string HTML |
311 | 311 | */ |
312 | - private function buildSummary( $results ) { |
|
312 | + private function buildSummary($results) { |
|
313 | 313 | $statuses = array(); |
314 | - foreach ( $results as $result ) { |
|
315 | - $status = strtolower( $result->getComparisonResult()->getStatus() ); |
|
316 | - if ( array_key_exists( $status, $statuses ) ) { |
|
314 | + foreach ($results as $result) { |
|
315 | + $status = strtolower($result->getComparisonResult()->getStatus()); |
|
316 | + if (array_key_exists($status, $statuses)) { |
|
317 | 317 | $statuses[$status]++; |
318 | 318 | } else { |
319 | 319 | $statuses[$status] = 1; |
@@ -321,15 +321,15 @@ discard block |
||
321 | 321 | } |
322 | 322 | |
323 | 323 | $statusElements = array(); |
324 | - foreach ( $statuses as $status => $count ) { |
|
325 | - if ( $count > 0 ) { |
|
326 | - $statusElements[] = $this->formatStatus( $status ) . ': ' . $count; |
|
324 | + foreach ($statuses as $status => $count) { |
|
325 | + if ($count > 0) { |
|
326 | + $statusElements[] = $this->formatStatus($status) . ': ' . $count; |
|
327 | 327 | } |
328 | 328 | } |
329 | 329 | $summary = |
330 | - Html::openElement( 'p' ) |
|
331 | - . implode( ', ', $statusElements ) |
|
332 | - . Html::closeElement( 'p' ); |
|
330 | + Html::openElement('p') |
|
331 | + . implode(', ', $statusElements) |
|
332 | + . Html::closeElement('p'); |
|
333 | 333 | |
334 | 334 | return $summary; |
335 | 335 | } |
@@ -343,16 +343,16 @@ discard block |
||
343 | 343 | * |
344 | 344 | * @return string HTML |
345 | 345 | */ |
346 | - private function formatStatus( $status ) { |
|
347 | - $messageKey = 'wbqev-crosscheck-status-' . strtolower( $status ); |
|
346 | + private function formatStatus($status) { |
|
347 | + $messageKey = 'wbqev-crosscheck-status-' . strtolower($status); |
|
348 | 348 | |
349 | 349 | $formattedStatus = |
350 | 350 | Html::element( |
351 | 351 | 'span', |
352 | - array ( |
|
353 | - 'class' => 'wbqev-status wbqev-status-' . htmlspecialchars( $status ) |
|
352 | + array( |
|
353 | + 'class' => 'wbqev-status wbqev-status-' . htmlspecialchars($status) |
|
354 | 354 | ), |
355 | - $this->msg( $messageKey )->text() |
|
355 | + $this->msg($messageKey)->text() |
|
356 | 356 | ); |
357 | 357 | |
358 | 358 | return $formattedStatus; |
@@ -369,29 +369,29 @@ discard block |
||
369 | 369 | * |
370 | 370 | * @return string HTML |
371 | 371 | */ |
372 | - private function formatDataValues( $dataValues, $linking = true, $separator = null ) { |
|
373 | - if ( $dataValues instanceof DataValue ) { |
|
374 | - $dataValues = array( $dataValues ); |
|
372 | + private function formatDataValues($dataValues, $linking = true, $separator = null) { |
|
373 | + if ($dataValues instanceof DataValue) { |
|
374 | + $dataValues = array($dataValues); |
|
375 | 375 | } |
376 | 376 | |
377 | 377 | $formattedDataValues = array(); |
378 | - foreach ( $dataValues as $dataValue ) { |
|
379 | - if ( $dataValue instanceof EntityIdValue ) { |
|
380 | - if ( $linking ) { |
|
381 | - $formattedDataValues[] = $this->entityIdLinkFormatter->formatEntityId( $dataValue->getEntityId() ); |
|
378 | + foreach ($dataValues as $dataValue) { |
|
379 | + if ($dataValue instanceof EntityIdValue) { |
|
380 | + if ($linking) { |
|
381 | + $formattedDataValues[] = $this->entityIdLinkFormatter->formatEntityId($dataValue->getEntityId()); |
|
382 | 382 | } else { |
383 | - $formattedDataValues[] = $this->entityIdLabelFormatter->formatEntityId( $dataValue->getEntityId() ); |
|
383 | + $formattedDataValues[] = $this->entityIdLabelFormatter->formatEntityId($dataValue->getEntityId()); |
|
384 | 384 | } |
385 | 385 | } else { |
386 | - $formattedDataValues[] = $this->dataValueFormatter->format( $dataValue ); |
|
386 | + $formattedDataValues[] = $this->dataValueFormatter->format($dataValue); |
|
387 | 387 | } |
388 | 388 | } |
389 | 389 | |
390 | - if ( $separator ) { |
|
391 | - return implode( $separator, $formattedDataValues ); |
|
390 | + if ($separator) { |
|
391 | + return implode($separator, $formattedDataValues); |
|
392 | 392 | } |
393 | 393 | |
394 | - return $this->getLanguage()->commaList( $formattedDataValues ); |
|
394 | + return $this->getLanguage()->commaList($formattedDataValues); |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | /** |
@@ -399,31 +399,31 @@ discard block |
||
399 | 399 | * |
400 | 400 | * @return string HTML |
401 | 401 | */ |
402 | - private function buildResultTable( $results ) { |
|
402 | + private function buildResultTable($results) { |
|
403 | 403 | $table = new HtmlTableBuilder( |
404 | 404 | array( |
405 | 405 | new HtmlTableHeaderBuilder( |
406 | - $this->msg( 'wbqev-crosscheck-result-table-header-status' )->escaped(), |
|
406 | + $this->msg('wbqev-crosscheck-result-table-header-status')->escaped(), |
|
407 | 407 | true |
408 | 408 | ), |
409 | 409 | new HtmlTableHeaderBuilder( |
410 | - $this->msg( 'datatypes-type-wikibase-property' )->escaped(), |
|
410 | + $this->msg('datatypes-type-wikibase-property')->escaped(), |
|
411 | 411 | true |
412 | 412 | ), |
413 | 413 | new HtmlTableHeaderBuilder( |
414 | - $this->msg( 'wbqev-crosscheck-result-table-header-local-value' )->escaped() |
|
414 | + $this->msg('wbqev-crosscheck-result-table-header-local-value')->escaped() |
|
415 | 415 | ), |
416 | 416 | new HtmlTableHeaderBuilder( |
417 | - $this->msg( 'wbqev-crosscheck-result-table-header-external-value' )->escaped() |
|
417 | + $this->msg('wbqev-crosscheck-result-table-header-external-value')->escaped() |
|
418 | 418 | ), |
419 | 419 | new HtmlTableHeaderBuilder( |
420 | - $this->msg( 'wbqev-crosscheck-result-table-header-references' )->escaped(), |
|
420 | + $this->msg('wbqev-crosscheck-result-table-header-references')->escaped(), |
|
421 | 421 | true |
422 | 422 | ), |
423 | 423 | new HtmlTableHeaderBuilder( |
424 | 424 | Linker::linkKnown( |
425 | - self::getTitleFor( 'ExternalDbs' ), |
|
426 | - $this->msg( 'wbqev-crosscheck-result-table-header-external-source' )->escaped() |
|
425 | + self::getTitleFor('ExternalDbs'), |
|
426 | + $this->msg('wbqev-crosscheck-result-table-header-external-source')->escaped() |
|
427 | 427 | ), |
428 | 428 | true, |
429 | 429 | true |
@@ -432,28 +432,28 @@ discard block |
||
432 | 432 | true |
433 | 433 | ); |
434 | 434 | |
435 | - foreach ( $results as $result ) { |
|
436 | - $status = $this->formatStatus( $result->getComparisonResult()->getStatus() ); |
|
437 | - $propertyId = $this->entityIdLinkFormatter->formatEntityId( $result->getPropertyId() ); |
|
438 | - $localValue = $this->formatDataValues( $result->getComparisonResult()->getLocalValue() ); |
|
435 | + foreach ($results as $result) { |
|
436 | + $status = $this->formatStatus($result->getComparisonResult()->getStatus()); |
|
437 | + $propertyId = $this->entityIdLinkFormatter->formatEntityId($result->getPropertyId()); |
|
438 | + $localValue = $this->formatDataValues($result->getComparisonResult()->getLocalValue()); |
|
439 | 439 | $externalValue = $this->formatDataValues( |
440 | 440 | $result->getComparisonResult()->getExternalValues(), |
441 | 441 | true, |
442 | - Html::element( 'br' ) |
|
442 | + Html::element('br') |
|
443 | 443 | ); |
444 | 444 | $referenceStatus = $this->msg( |
445 | 445 | 'wbqev-crosscheck-status-' . $result->getReferenceResult()->getStatus() |
446 | 446 | )->text(); |
447 | - $dataSource = $this->entityIdLinkFormatter->formatEntityId( $result->getDumpMetaInformation()->getSourceItemId() ); |
|
447 | + $dataSource = $this->entityIdLinkFormatter->formatEntityId($result->getDumpMetaInformation()->getSourceItemId()); |
|
448 | 448 | |
449 | 449 | $table->appendRow( |
450 | 450 | array( |
451 | - new HtmlTableCellBuilder( $status, array(), true ), |
|
452 | - new HtmlTableCellBuilder( $propertyId, array(), true ), |
|
453 | - new HtmlTableCellBuilder( $localValue, array(), true ), |
|
454 | - new HtmlTableCellBuilder( $externalValue, array(), true ), |
|
455 | - new HtmlTableCellBuilder( $referenceStatus, array() ), |
|
456 | - new HtmlTableCellBuilder( $dataSource, array(), true ) |
|
451 | + new HtmlTableCellBuilder($status, array(), true), |
|
452 | + new HtmlTableCellBuilder($propertyId, array(), true), |
|
453 | + new HtmlTableCellBuilder($localValue, array(), true), |
|
454 | + new HtmlTableCellBuilder($externalValue, array(), true), |
|
455 | + new HtmlTableCellBuilder($referenceStatus, array()), |
|
456 | + new HtmlTableCellBuilder($dataSource, array(), true) |
|
457 | 457 | ) |
458 | 458 | ); |
459 | 459 | } |
@@ -47,7 +47,6 @@ |
||
47 | 47 | |
48 | 48 | /** |
49 | 49 | * @param TermLookup $termLookup |
50 | - * @param EntityTitleLookup $entityTitleLookup |
|
51 | 50 | * @param DumpMetaInformationLookup $dumpMetaInformationRepo |
52 | 51 | */ |
53 | 52 | public function __construct( |
@@ -54,10 +54,10 @@ discard block |
||
54 | 54 | TermLookup $termLookup, |
55 | 55 | EntityIdHtmlLinkFormatterFactory $entityIdHtmlLinkFormatterFactory, |
56 | 56 | DumpMetaInformationLookup $dumpMetaInformationRepo ) { |
57 | - parent::__construct( 'ExternalDbs' ); |
|
57 | + parent::__construct('ExternalDbs'); |
|
58 | 58 | |
59 | 59 | $this->entityIdLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter( |
60 | - new LanguageLabelDescriptionLookup( $termLookup, $this->getLanguage()->getCode() ) |
|
60 | + new LanguageLabelDescriptionLookup($termLookup, $this->getLanguage()->getCode()) |
|
61 | 61 | ); |
62 | 62 | |
63 | 63 | $this->dumpMetaInformationRepo = $dumpMetaInformationRepo; |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * @return string |
79 | 79 | */ |
80 | 80 | public function getDescription() { |
81 | - return $this->msg( 'wbqev-externaldbs' )->text(); |
|
81 | + return $this->msg('wbqev-externaldbs')->text(); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -86,51 +86,51 @@ discard block |
||
86 | 86 | * |
87 | 87 | * @param string|null $subPage |
88 | 88 | */ |
89 | - public function execute( $subPage ) { |
|
89 | + public function execute($subPage) { |
|
90 | 90 | $out = $this->getOutput(); |
91 | 91 | |
92 | 92 | $this->setHeaders(); |
93 | 93 | |
94 | 94 | $out->addHTML( |
95 | - Html::openElement( 'p' ) |
|
96 | - . $this->msg( 'wbqev-externaldbs-instructions' )->parse() |
|
97 | - . Html::closeElement( 'p' ) |
|
98 | - . Html::openElement( 'h3' ) |
|
99 | - . $this->msg( 'wbqev-externaldbs-overview-headline' )->parse() |
|
100 | - . Html::closeElement( 'h3' ) |
|
95 | + Html::openElement('p') |
|
96 | + . $this->msg('wbqev-externaldbs-instructions')->parse() |
|
97 | + . Html::closeElement('p') |
|
98 | + . Html::openElement('h3') |
|
99 | + . $this->msg('wbqev-externaldbs-overview-headline')->parse() |
|
100 | + . Html::closeElement('h3') |
|
101 | 101 | ); |
102 | 102 | |
103 | 103 | $dumps = $this->dumpMetaInformationRepo->getAll(); |
104 | - if ( count( $dumps ) > 0 ) { |
|
104 | + if (count($dumps) > 0) { |
|
105 | 105 | $groupedDumpMetaInformation = array(); |
106 | - foreach ( $dumps as $dump ) { |
|
106 | + foreach ($dumps as $dump) { |
|
107 | 107 | $sourceItemId = $dump->getSourceItemId()->getSerialization(); |
108 | 108 | $groupedDumpMetaInformation[$sourceItemId][] = $dump; |
109 | 109 | } |
110 | 110 | |
111 | 111 | $table = new HtmlTableBuilder( |
112 | 112 | array( |
113 | - $this->msg( 'wbqev-externaldbs-name' )->escaped(), |
|
114 | - $this->msg( 'wbqev-externaldbs-id' )->escaped(), |
|
115 | - $this->msg( 'wbqev-externaldbs-import-date' )->escaped(), |
|
116 | - $this->msg( 'wbqev-externaldbs-language' )->escaped(), |
|
117 | - $this->msg( 'wbqev-externaldbs-source-urls' )->escaped(), |
|
118 | - $this->msg( 'wbqev-externaldbs-size' )->escaped(), |
|
119 | - $this->msg( 'wbqev-externaldbs-license' )->escaped() |
|
113 | + $this->msg('wbqev-externaldbs-name')->escaped(), |
|
114 | + $this->msg('wbqev-externaldbs-id')->escaped(), |
|
115 | + $this->msg('wbqev-externaldbs-import-date')->escaped(), |
|
116 | + $this->msg('wbqev-externaldbs-language')->escaped(), |
|
117 | + $this->msg('wbqev-externaldbs-source-urls')->escaped(), |
|
118 | + $this->msg('wbqev-externaldbs-size')->escaped(), |
|
119 | + $this->msg('wbqev-externaldbs-license')->escaped() |
|
120 | 120 | ), |
121 | 121 | true |
122 | 122 | ); |
123 | 123 | |
124 | - foreach ( $groupedDumpMetaInformation as $sourceItemId => $dumpMetaInformation ) { |
|
125 | - $table->appendRows( $this->getRowGroup( $dumpMetaInformation ) ); |
|
124 | + foreach ($groupedDumpMetaInformation as $sourceItemId => $dumpMetaInformation) { |
|
125 | + $table->appendRows($this->getRowGroup($dumpMetaInformation)); |
|
126 | 126 | } |
127 | 127 | |
128 | - $out->addHTML( $table->toHtml() ); |
|
128 | + $out->addHTML($table->toHtml()); |
|
129 | 129 | } else { |
130 | 130 | $out->addHTML( |
131 | - Html::openElement( 'p' ) |
|
132 | - . $this->msg( 'wbqev-externaldbs-no-databases' )->escaped() |
|
133 | - . Html::closeElement( 'p' ) |
|
131 | + Html::openElement('p') |
|
132 | + . $this->msg('wbqev-externaldbs-no-databases')->escaped() |
|
133 | + . Html::closeElement('p') |
|
134 | 134 | ); |
135 | 135 | } |
136 | 136 | } |
@@ -142,12 +142,12 @@ discard block |
||
142 | 142 | * |
143 | 143 | * @return array |
144 | 144 | */ |
145 | - private function getRowGroup( array $dumpMetaInformationGroup ) { |
|
145 | + private function getRowGroup(array $dumpMetaInformationGroup) { |
|
146 | 146 | $rows = array(); |
147 | 147 | |
148 | - foreach ( $dumpMetaInformationGroup as $dumpMetaInformation ) { |
|
148 | + foreach ($dumpMetaInformationGroup as $dumpMetaInformation) { |
|
149 | 149 | $dumpId = $dumpMetaInformation->getDumpId(); |
150 | - $importDate = $this->getLanguage()->timeanddate( $dumpMetaInformation->getImportDate() ); |
|
150 | + $importDate = $this->getLanguage()->timeanddate($dumpMetaInformation->getImportDate()); |
|
151 | 151 | $language = Language::fetchLanguageName( |
152 | 152 | $dumpMetaInformation->getLanguageCode(), |
153 | 153 | $this->getLanguage()->getCode() |
@@ -156,23 +156,23 @@ discard block |
||
156 | 156 | $dumpMetaInformation->getSourceUrl(), |
157 | 157 | $dumpMetaInformation->getSourceUrl() |
158 | 158 | ); |
159 | - $size = $this->getLanguage()->formatSize( $dumpMetaInformation->getSize() ); |
|
160 | - $license = $this->entityIdLinkFormatter->formatEntityId( $dumpMetaInformation->getLicenseItemId() ); |
|
159 | + $size = $this->getLanguage()->formatSize($dumpMetaInformation->getSize()); |
|
160 | + $license = $this->entityIdLinkFormatter->formatEntityId($dumpMetaInformation->getLicenseItemId()); |
|
161 | 161 | $rows[] = array( |
162 | - new HtmlTableCellBuilder( $dumpId ), |
|
163 | - new HtmlTableCellBuilder( $importDate ), |
|
164 | - new HtmlTableCellBuilder( $language ), |
|
165 | - new HtmlTableCellBuilder( $sourceUrl, array(), true ), |
|
166 | - new HtmlTableCellBuilder( $size ), |
|
167 | - new HtmlTableCellBuilder( $license, array(), true ) |
|
162 | + new HtmlTableCellBuilder($dumpId), |
|
163 | + new HtmlTableCellBuilder($importDate), |
|
164 | + new HtmlTableCellBuilder($language), |
|
165 | + new HtmlTableCellBuilder($sourceUrl, array(), true), |
|
166 | + new HtmlTableCellBuilder($size), |
|
167 | + new HtmlTableCellBuilder($license, array(), true) |
|
168 | 168 | ); |
169 | 169 | } |
170 | 170 | |
171 | 171 | array_unshift( |
172 | 172 | $rows[0], |
173 | 173 | new HtmlTableCellBuilder( |
174 | - $this->entityIdLinkFormatter->formatEntityId( $dumpMetaInformationGroup[0]->getSourceItemId() ), |
|
175 | - array( 'rowspan' => (string)count( $dumpMetaInformationGroup ) ), |
|
174 | + $this->entityIdLinkFormatter->formatEntityId($dumpMetaInformationGroup[0]->getSourceItemId()), |
|
175 | + array('rowspan' => (string)count($dumpMetaInformationGroup)), |
|
176 | 176 | true |
177 | 177 | ) |
178 | 178 | ); |
@@ -11,6 +11,6 @@ |
||
11 | 11 | |
12 | 12 | /** English (English) */ |
13 | 13 | $specialPageAliases['en'] = array( |
14 | - 'CrossCheck' => array( 'CrossCheck', 'Cross Check' ), |
|
15 | - 'ExternalDbs' => array( 'ExternalDbs', 'External Dbs' ), |
|
14 | + 'CrossCheck' => array('CrossCheck', 'Cross Check'), |
|
15 | + 'ExternalDbs' => array('ExternalDbs', 'External Dbs'), |
|
16 | 16 | ); |
17 | 17 | \ No newline at end of file |
@@ -7,15 +7,15 @@ |
||
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 ) { |
|
18 | + public static function onUnitTestsList(&$paths) { |
|
19 | 19 | $paths[] = __DIR__ . '/tests/phpunit'; |
20 | 20 | return true; |
21 | 21 | } |
@@ -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 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * @param TermIndex $termIndex |
27 | 27 | * @param StringNormalizer $stringNormalizer |
28 | 28 | */ |
29 | - public function __construct( TermIndex $termIndex, StringNormalizer $stringNormalizer ) { |
|
29 | + public function __construct(TermIndex $termIndex, StringNormalizer $stringNormalizer) { |
|
30 | 30 | $this->termIndex = $termIndex; |
31 | 31 | $this->stringNormalizer = $stringNormalizer; |
32 | 32 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @return StringComparer |
69 | 69 | */ |
70 | 70 | private function newStringComparer() { |
71 | - return new StringComparer( $this->stringNormalizer ); |
|
71 | + return new StringComparer($this->stringNormalizer); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -20,8 +20,8 @@ discard block |
||
20 | 20 | /** |
21 | 21 | * @param DataValueComparer[] $dataValueComparers |
22 | 22 | */ |
23 | - public function __construct( array $dataValueComparers = array() ) { |
|
24 | - $this->assertAreDataValueComparer( $dataValueComparers ); |
|
23 | + public function __construct(array $dataValueComparers = array()) { |
|
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 |