Completed
Push — master ( 411438...5a9354 )
by
unknown
21s
created
src/Api/CheckConstraints.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types=1);
4 4
 
5 5
 namespace WikibaseQuality\ConstraintReport\Api;
6 6
 
@@ -81,11 +81,11 @@  discard block
 block discarded – undo
81 81
 		CheckResultsRendererFactory $checkResultsRendererFactory,
82 82
 		IBufferingStatsdDataFactory $dataFactory
83 83
 	) {
84
-		parent::__construct( $main, $name );
84
+		parent::__construct($main, $name);
85 85
 		$this->entityIdParser = $entityIdParser;
86 86
 		$this->statementGuidValidator = $statementGuidValidator;
87
-		$this->resultBuilder = $apiHelperFactory->getResultBuilder( $this );
88
-		$this->errorReporter = $apiHelperFactory->getErrorReporter( $this );
87
+		$this->resultBuilder = $apiHelperFactory->getResultBuilder($this);
88
+		$this->errorReporter = $apiHelperFactory->getErrorReporter($this);
89 89
 		$this->resultsSource = $resultsSource;
90 90
 		$this->checkResultsRendererFactory = $checkResultsRendererFactory;
91 91
 		$this->dataFactory = $dataFactory;
@@ -101,14 +101,14 @@  discard block
 block discarded – undo
101 101
 
102 102
 		$params = $this->extractRequestParams();
103 103
 
104
-		$this->validateParameters( $params );
105
-		$entityIds = $this->parseEntityIds( $params );
106
-		$claimIds = $this->parseClaimIds( $params );
104
+		$this->validateParameters($params);
105
+		$entityIds = $this->parseEntityIds($params);
106
+		$claimIds = $this->parseClaimIds($params);
107 107
 		$constraintIDs = $params[self::PARAM_CONSTRAINT_ID];
108 108
 		$statuses = $params[self::PARAM_STATUS];
109 109
 
110 110
 		$checkResultsRenderer = $this->checkResultsRendererFactory
111
-			->getCheckResultsRenderer( $this->getLanguage(), $this );
111
+			->getCheckResultsRenderer($this->getLanguage(), $this);
112 112
 
113 113
 		$this->getResult()->addValue(
114 114
 			null,
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 				)
123 123
 			)->getArray()
124 124
 		);
125
-		$this->resultBuilder->markSuccess( 1 );
125
+		$this->resultBuilder->markSuccess(1);
126 126
 	}
127 127
 
128 128
 	/**
@@ -130,24 +130,24 @@  discard block
 block discarded – undo
130 130
 	 *
131 131
 	 * @return EntityId[]
132 132
 	 */
133
-	private function parseEntityIds( array $params ): array {
133
+	private function parseEntityIds(array $params): array {
134 134
 		$ids = $params[self::PARAM_ID];
135 135
 
136
-		if ( $ids === null ) {
136
+		if ($ids === null) {
137 137
 			return [];
138
-		} elseif ( $ids === [] ) {
138
+		} elseif ($ids === []) {
139 139
 			$this->errorReporter->dieError(
140
-				'If ' . self::PARAM_ID . ' is specified, it must be nonempty.', 'no-data' );
140
+				'If '.self::PARAM_ID.' is specified, it must be nonempty.', 'no-data' );
141 141
 		}
142 142
 
143
-		return array_map( function ( $id ) {
143
+		return array_map(function($id) {
144 144
 			try {
145
-				return $this->entityIdParser->parse( $id );
146
-			} catch ( EntityIdParsingException $e ) {
145
+				return $this->entityIdParser->parse($id);
146
+			} catch (EntityIdParsingException $e) {
147 147
 				$this->errorReporter->dieError(
148
-					"Invalid id: $id", 'invalid-entity-id', 0, [ self::PARAM_ID => $id ] );
148
+					"Invalid id: $id", 'invalid-entity-id', 0, [self::PARAM_ID => $id] );
149 149
 			}
150
-		}, $ids );
150
+		}, $ids);
151 151
 	}
152 152
 
153 153
 	/**
@@ -155,35 +155,35 @@  discard block
 block discarded – undo
155 155
 	 *
156 156
 	 * @return string[]
157 157
 	 */
158
-	private function parseClaimIds( array $params ): array {
158
+	private function parseClaimIds(array $params): array {
159 159
 		$ids = $params[self::PARAM_CLAIM_ID];
160 160
 
161
-		if ( $ids === null ) {
161
+		if ($ids === null) {
162 162
 			return [];
163
-		} elseif ( $ids === [] ) {
163
+		} elseif ($ids === []) {
164 164
 			$this->errorReporter->dieError(
165
-				'If ' . self::PARAM_CLAIM_ID . ' is specified, it must be nonempty.', 'no-data' );
165
+				'If '.self::PARAM_CLAIM_ID.' is specified, it must be nonempty.', 'no-data' );
166 166
 		}
167 167
 
168
-		foreach ( $ids as $id ) {
169
-			if ( !$this->statementGuidValidator->validate( $id ) ) {
168
+		foreach ($ids as $id) {
169
+			if (!$this->statementGuidValidator->validate($id)) {
170 170
 				$this->errorReporter->dieError(
171
-					"Invalid claim id: $id", 'invalid-guid', 0, [ self::PARAM_CLAIM_ID => $id ] );
171
+					"Invalid claim id: $id", 'invalid-guid', 0, [self::PARAM_CLAIM_ID => $id] );
172 172
 			}
173 173
 		}
174 174
 
175 175
 		return $ids;
176 176
 	}
177 177
 
178
-	private function validateParameters( array $params ): void {
179
-		if ( $params[self::PARAM_CONSTRAINT_ID] !== null
180
-			 && empty( $params[self::PARAM_CONSTRAINT_ID] )
178
+	private function validateParameters(array $params): void {
179
+		if ($params[self::PARAM_CONSTRAINT_ID] !== null
180
+			 && empty($params[self::PARAM_CONSTRAINT_ID])
181 181
 		) {
182 182
 			$paramConstraintId = self::PARAM_CONSTRAINT_ID;
183 183
 			$this->errorReporter->dieError(
184 184
 				"If $paramConstraintId is specified, it must be nonempty.", 'no-data' );
185 185
 		}
186
-		if ( $params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null ) {
186
+		if ($params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null) {
187 187
 			$paramId = self::PARAM_ID;
188 188
 			$paramClaimId = self::PARAM_CLAIM_ID;
189 189
 			$this->errorReporter->dieError(
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 				],
225 225
 				ParamValidator::PARAM_ISMULTI => true,
226 226
 				ParamValidator::PARAM_ALL => true,
227
-				ParamValidator::PARAM_DEFAULT => implode( '|', CachingResultsSource::CACHED_STATUSES ),
227
+				ParamValidator::PARAM_DEFAULT => implode('|', CachingResultsSource::CACHED_STATUSES),
228 228
 				ApiBase::PARAM_HELP_MSG_PER_VALUE => [],
229 229
 			],
230 230
 		];
Please login to merge, or discard this patch.