Completed
Push — master ( 400d3d...683449 )
by
unknown
02:21
created
api/RunCrossCheck.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -172,7 +172,7 @@
 block discarded – undo
172 172
 	/**
173 173
 	 * Writes output for CrossCheckResultList
174 174
 	 *
175
-	 * @param array $resultLists
175
+	 * @param \WikibaseQuality\ExternalValidation\CrossCheck\Result\CrossCheckResultList[] $resultLists
176 176
 	 */
177 177
 	private function writeResultOutput( array $resultLists ) {
178 178
 		$serializer = $this->serializerFactory->newCrossCheckResultListSerializer();
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	 *
65 65
 	 * @return self
66 66
 	 */
67
-	public static function newFromGlobalState( ApiMain $main, $name, $prefix = '' ) {
67
+	public static function newFromGlobalState(ApiMain $main, $name, $prefix = '') {
68 68
 		$repo = WikibaseRepo::getDefaultInstance();
69 69
 		$externalValidationServices = ExternalValidationServices::getDefaultInstance();
70 70
 
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 			$repo->getStatementGuidValidator(),
77 77
 			$externalValidationServices->getCrossCheckInteractor(),
78 78
 			$externalValidationServices->getSerializerFactory(),
79
-			$repo->getApiHelperFactory( RequestContext::getMain() )
79
+			$repo->getApiHelperFactory(RequestContext::getMain())
80 80
 		);
81 81
 	}
82 82
 
@@ -100,14 +100,14 @@  discard block
 block discarded – undo
100 100
 		SerializerFactory $serializerFactory,
101 101
 		ApiHelperFactory $apiHelperFactory
102 102
 	) {
103
-		parent::__construct( $main, $name, $prefix );
103
+		parent::__construct($main, $name, $prefix);
104 104
 
105 105
 		$this->entityIdParser = $entityIdParser;
106 106
 		$this->statementGuidValidator = $statementGuidValidator;
107 107
 		$this->crossCheckInteractor = $crossCheckInteractor;
108 108
 		$this->serializerFactory = $serializerFactory;
109
-		$this->resultBuilder = $apiHelperFactory->getResultBuilder( $this );
110
-		$this->errorReporter = $apiHelperFactory->getErrorReporter( $this );
109
+		$this->resultBuilder = $apiHelperFactory->getResultBuilder($this);
110
+		$this->errorReporter = $apiHelperFactory->getErrorReporter($this);
111 111
 	}
112 112
 
113 113
 	/**
@@ -116,34 +116,34 @@  discard block
 block discarded – undo
116 116
 	public function execute() {
117 117
 		$params = $this->extractRequestParams();
118 118
 
119
-		if ( $params['entities'] && $params['claims'] ) {
119
+		if ($params['entities'] && $params['claims']) {
120 120
 			$this->errorReporter->dieError(
121 121
 				'Either provide the ids of entities or ids of claims, that should be cross-checked.',
122 122
 				'param-invalid'
123 123
 			);
124 124
 			throw new LogicException();
125
-		} elseif ( $params['entities'] ) {
126
-			$entityIds = $this->parseEntityIds( $params['entities'] );
127
-			if ( $params['properties'] ) {
128
-				$propertyIds = $this->parseEntityIds( $params['properties'] );
129
-				$resultLists = $this->crossCheckInteractor->crossCheckEntitiesByIdWithProperties( $entityIds, $propertyIds );
125
+		} elseif ($params['entities']) {
126
+			$entityIds = $this->parseEntityIds($params['entities']);
127
+			if ($params['properties']) {
128
+				$propertyIds = $this->parseEntityIds($params['properties']);
129
+				$resultLists = $this->crossCheckInteractor->crossCheckEntitiesByIdWithProperties($entityIds, $propertyIds);
130 130
 			} else {
131
-				$resultLists = $this->crossCheckInteractor->crossCheckEntitiesByIds( $entityIds );
131
+				$resultLists = $this->crossCheckInteractor->crossCheckEntitiesByIds($entityIds);
132 132
 			}
133
-		} elseif ( $params['claims'] ) {
133
+		} elseif ($params['claims']) {
134 134
 			$guids = $params['claims'];
135
-			$this->assertAreValidClaimGuids( $guids );
136
-			$resultLists = $this->crossCheckInteractor->crossCheckStatementsByGuids( $guids );
135
+			$this->assertAreValidClaimGuids($guids);
136
+			$resultLists = $this->crossCheckInteractor->crossCheckStatementsByGuids($guids);
137 137
 		} else {
138 138
 			$this->errorReporter->dieWithError(
139
-				[ 'wikibase-api-param-missing', 'entities|claims' ],
139
+				['wikibase-api-param-missing', 'entities|claims'],
140 140
 				'param-missing'
141 141
 			);
142 142
 			throw new LogicException();
143 143
 		}
144 144
 
145 145
 		// Print result lists
146
-		$this->writeResultOutput( $resultLists );
146
+		$this->writeResultOutput($resultLists);
147 147
 	}
148 148
 
149 149
 	/**
@@ -151,9 +151,9 @@  discard block
 block discarded – undo
151 151
 	 *
152 152
 	 * @return EntityId[]
153 153
 	 */
154
-	private function parseEntityIds( array $entityIds ) {
154
+	private function parseEntityIds(array $entityIds) {
155 155
 		return array_map(
156
-			[ $this->entityIdParser, 'parse' ],
156
+			[$this->entityIdParser, 'parse'],
157 157
 			$entityIds
158 158
 		);
159 159
 	}
@@ -161,10 +161,10 @@  discard block
 block discarded – undo
161 161
 	/**
162 162
 	 * @param string[] $guids
163 163
 	 */
164
-	private function assertAreValidClaimGuids( array $guids ) {
165
-		foreach ( $guids as $guid ) {
166
-			if ( $this->statementGuidValidator->validateFormat( $guid ) === false ) {
167
-				$this->errorReporter->dieError( 'Invalid claim guid.', 'invalid-guid' );
164
+	private function assertAreValidClaimGuids(array $guids) {
165
+		foreach ($guids as $guid) {
166
+			if ($this->statementGuidValidator->validateFormat($guid) === false) {
167
+				$this->errorReporter->dieError('Invalid claim guid.', 'invalid-guid');
168 168
 			}
169 169
 		}
170 170
 	}
@@ -174,13 +174,13 @@  discard block
 block discarded – undo
174 174
 	 *
175 175
 	 * @param array $resultLists
176 176
 	 */
177
-	private function writeResultOutput( array $resultLists ) {
177
+	private function writeResultOutput(array $resultLists) {
178 178
 		$serializer = $this->serializerFactory->newCrossCheckResultListSerializer();
179 179
 
180 180
 		$output = [];
181
-		foreach ( $resultLists as $entityId => $resultList ) {
182
-			if ( $resultList ) {
183
-				$serializedResultList = $serializer->serialize( $resultList );
181
+		foreach ($resultLists as $entityId => $resultList) {
182
+			if ($resultList) {
183
+				$serializedResultList = $serializer->serialize($resultList);
184 184
 
185 185
 				$output[$entityId] = $serializedResultList;
186 186
 			} else {
@@ -190,10 +190,10 @@  discard block
 block discarded – undo
190 190
 			}
191 191
 		}
192 192
 
193
-		$this->getResult()->setIndexedTagName( $output, 'entity' );
194
-		$this->getResult()->setArrayType( $output, 'kvp', 'id' );
195
-		$this->getResult()->addValue( null, 'results', $output );
196
-		$this->resultBuilder->markSuccess( 1 );
193
+		$this->getResult()->setIndexedTagName($output, 'entity');
194
+		$this->getResult()->setArrayType($output, 'kvp', 'id');
195
+		$this->getResult()->addValue(null, 'results', $output);
196
+		$this->resultBuilder->markSuccess(1);
197 197
 	}
198 198
 
199 199
 	/**
Please login to merge, or discard this patch.