Completed
Push — master ( dcb245...59cb5b )
by
unknown
06:35
created
src/Api/CheckConstraints.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -83,14 +83,14 @@  discard block
 block discarded – undo
83 83
 
84 84
 		$language = $repo->getUserLanguage();
85 85
 		$formatterOptions = new FormatterOptions();
86
-		$formatterOptions->setOption( SnakFormatter::OPT_LANG, $language->getCode() );
86
+		$formatterOptions->setOption(SnakFormatter::OPT_LANG, $language->getCode());
87 87
 		$valueFormatterFactory = $repo->getValueFormatterFactory();
88
-		$valueFormatter = $valueFormatterFactory->getValueFormatter( SnakFormatter::FORMAT_HTML, $formatterOptions );
88
+		$valueFormatter = $valueFormatterFactory->getValueFormatter(SnakFormatter::FORMAT_HTML, $formatterOptions);
89 89
 
90 90
 		$entityIdHtmlLinkFormatterFactory = $repo->getEntityIdHtmlLinkFormatterFactory();
91
-		$entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter( $language );
91
+		$entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter($language);
92 92
 		$entityIdLabelFormatterFactory = new EntityIdLabelFormatterFactory();
93
-		$entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter( $language );
93
+		$entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter($language);
94 94
 
95 95
 		$checkResultsRenderer = new CheckResultsRenderer(
96 96
 			$repo->getEntityTitleLookup(),
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 			$name,
109 109
 			$repo->getEntityIdParser(),
110 110
 			$repo->getStatementGuidValidator(),
111
-			$repo->getApiHelperFactory( RequestContext::getMain() ),
111
+			$repo->getApiHelperFactory(RequestContext::getMain()),
112 112
 			$resultsSource,
113 113
 			$checkResultsRenderer,
114 114
 			$dataFactory
@@ -135,11 +135,11 @@  discard block
 block discarded – undo
135 135
 		CheckResultsRenderer $checkResultsRenderer,
136 136
 		IBufferingStatsdDataFactory $dataFactory
137 137
 	) {
138
-		parent::__construct( $main, $name );
138
+		parent::__construct($main, $name);
139 139
 		$this->entityIdParser = $entityIdParser;
140 140
 		$this->statementGuidValidator = $statementGuidValidator;
141
-		$this->resultBuilder = $apiHelperFactory->getResultBuilder( $this );
142
-		$this->errorReporter = $apiHelperFactory->getErrorReporter( $this );
141
+		$this->resultBuilder = $apiHelperFactory->getResultBuilder($this);
142
+		$this->errorReporter = $apiHelperFactory->getErrorReporter($this);
143 143
 		$this->resultsSource = $resultsSource;
144 144
 		$this->checkResultsRenderer = $checkResultsRenderer;
145 145
 		$this->dataFactory = $dataFactory;
@@ -155,9 +155,9 @@  discard block
 block discarded – undo
155 155
 
156 156
 		$params = $this->extractRequestParams();
157 157
 
158
-		$this->validateParameters( $params );
159
-		$entityIds = $this->parseEntityIds( $params );
160
-		$claimIds = $this->parseClaimIds( $params );
158
+		$this->validateParameters($params);
159
+		$entityIds = $this->parseEntityIds($params);
160
+		$claimIds = $this->parseClaimIds($params);
161 161
 		$constraintIDs = $params[self::PARAM_CONSTRAINT_ID];
162 162
 		$statuses = $params[self::PARAM_STATUS];
163 163
 
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 				)
174 174
 			)->getArray()
175 175
 		);
176
-		$this->resultBuilder->markSuccess( 1 );
176
+		$this->resultBuilder->markSuccess(1);
177 177
 	}
178 178
 
179 179
 	/**
@@ -181,24 +181,24 @@  discard block
 block discarded – undo
181 181
 	 *
182 182
 	 * @return EntityId[]
183 183
 	 */
184
-	private function parseEntityIds( array $params ) {
184
+	private function parseEntityIds(array $params) {
185 185
 		$ids = $params[self::PARAM_ID];
186 186
 
187
-		if ( $ids === null ) {
187
+		if ($ids === null) {
188 188
 			return [];
189
-		} elseif ( $ids === [] ) {
189
+		} elseif ($ids === []) {
190 190
 			$this->errorReporter->dieError(
191
-				'If ' . self::PARAM_ID . ' is specified, it must be nonempty.', 'no-data' );
191
+				'If '.self::PARAM_ID.' is specified, it must be nonempty.', 'no-data' );
192 192
 		}
193 193
 
194
-		return array_map( function ( $id ) {
194
+		return array_map(function($id) {
195 195
 			try {
196
-				return $this->entityIdParser->parse( $id );
197
-			} catch ( EntityIdParsingException $e ) {
196
+				return $this->entityIdParser->parse($id);
197
+			} catch (EntityIdParsingException $e) {
198 198
 				$this->errorReporter->dieError(
199
-					"Invalid id: $id", 'invalid-entity-id', 0, [ self::PARAM_ID => $id ] );
199
+					"Invalid id: $id", 'invalid-entity-id', 0, [self::PARAM_ID => $id] );
200 200
 			}
201
-		}, $ids );
201
+		}, $ids);
202 202
 	}
203 203
 
204 204
 	/**
@@ -206,35 +206,35 @@  discard block
 block discarded – undo
206 206
 	 *
207 207
 	 * @return string[]
208 208
 	 */
209
-	private function parseClaimIds( array $params ) {
209
+	private function parseClaimIds(array $params) {
210 210
 		$ids = $params[self::PARAM_CLAIM_ID];
211 211
 
212
-		if ( $ids === null ) {
212
+		if ($ids === null) {
213 213
 			return [];
214
-		} elseif ( $ids === [] ) {
214
+		} elseif ($ids === []) {
215 215
 			$this->errorReporter->dieError(
216
-				'If ' . self::PARAM_CLAIM_ID . ' is specified, it must be nonempty.', 'no-data' );
216
+				'If '.self::PARAM_CLAIM_ID.' is specified, it must be nonempty.', 'no-data' );
217 217
 		}
218 218
 
219
-		foreach ( $ids as $id ) {
220
-			if ( !$this->statementGuidValidator->validate( $id ) ) {
219
+		foreach ($ids as $id) {
220
+			if (!$this->statementGuidValidator->validate($id)) {
221 221
 				$this->errorReporter->dieError(
222
-					"Invalid claim id: $id", 'invalid-guid', 0, [ self::PARAM_CLAIM_ID => $id ] );
222
+					"Invalid claim id: $id", 'invalid-guid', 0, [self::PARAM_CLAIM_ID => $id] );
223 223
 			}
224 224
 		}
225 225
 
226 226
 		return $ids;
227 227
 	}
228 228
 
229
-	private function validateParameters( array $params ) {
230
-		if ( $params[self::PARAM_CONSTRAINT_ID] !== null
231
-			 && empty( $params[self::PARAM_CONSTRAINT_ID] )
229
+	private function validateParameters(array $params) {
230
+		if ($params[self::PARAM_CONSTRAINT_ID] !== null
231
+			 && empty($params[self::PARAM_CONSTRAINT_ID])
232 232
 		) {
233 233
 			$paramConstraintId = self::PARAM_CONSTRAINT_ID;
234 234
 			$this->errorReporter->dieError(
235 235
 				"If $paramConstraintId is specified, it must be nonempty.", 'no-data' );
236 236
 		}
237
-		if ( $params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null ) {
237
+		if ($params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null) {
238 238
 			$paramId = self::PARAM_ID;
239 239
 			$paramClaimId = self::PARAM_CLAIM_ID;
240 240
 			$this->errorReporter->dieError(
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 				],
276 276
 				ApiBase::PARAM_ISMULTI => true,
277 277
 				ApiBase::PARAM_ALL => true,
278
-				ApiBase::PARAM_DFLT => implode( '|', CachingResultsSource::CACHED_STATUSES ),
278
+				ApiBase::PARAM_DFLT => implode('|', CachingResultsSource::CACHED_STATUSES),
279 279
 				ApiBase::PARAM_HELP_MSG_PER_VALUE => [],
280 280
 			],
281 281
 		];
Please login to merge, or discard this patch.