Completed
Push — master ( 17dea9...3c30b4 )
by
unknown
01:58 queued 01:05
created
src/Api/CheckConstraints.php 1 patch
Spacing   +32 added lines, -32 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
 
@@ -84,11 +84,11 @@  discard block
 block discarded – undo
84 84
 		CheckResultsRendererFactory $checkResultsRendererFactory,
85 85
 		StatsFactory $statsFactory
86 86
 	) {
87
-		parent::__construct( $main, $name );
87
+		parent::__construct($main, $name);
88 88
 		$this->entityIdParser = $entityIdParser;
89 89
 		$this->statementGuidValidator = $statementGuidValidator;
90
-		$this->resultBuilder = $apiHelperFactory->getResultBuilder( $this );
91
-		$this->errorReporter = $apiHelperFactory->getErrorReporter( $this );
90
+		$this->resultBuilder = $apiHelperFactory->getResultBuilder($this);
91
+		$this->errorReporter = $apiHelperFactory->getErrorReporter($this);
92 92
 		$this->resultsSource = $resultsSource;
93 93
 		$this->checkResultsRendererFactory = $checkResultsRendererFactory;
94 94
 		$this->statsFactory = $statsFactory;
@@ -99,19 +99,19 @@  discard block
 block discarded – undo
99 99
 	 */
100 100
 	public function execute() {
101 101
 		$baseKey = 'wikibase.quality.constraints.api.checkConstraints.execute';
102
-		$metric = $this->statsFactory->getCounter( 'check_constraints_execute_total' );
103
-		$metric->copyToStatsdAt( $baseKey )->increment();
102
+		$metric = $this->statsFactory->getCounter('check_constraints_execute_total');
103
+		$metric->copyToStatsdAt($baseKey)->increment();
104 104
 
105 105
 		$params = $this->extractRequestParams();
106 106
 
107
-		$this->validateParameters( $params );
108
-		$entityIds = $this->parseEntityIds( $params );
109
-		$claimIds = $this->parseClaimIds( $params );
107
+		$this->validateParameters($params);
108
+		$entityIds = $this->parseEntityIds($params);
109
+		$claimIds = $this->parseClaimIds($params);
110 110
 		$constraintIDs = $params[self::PARAM_CONSTRAINT_ID];
111 111
 		$statuses = $params[self::PARAM_STATUS];
112 112
 
113 113
 		$checkResultsRenderer = $this->checkResultsRendererFactory
114
-			->getCheckResultsRenderer( $this->getLanguage(), $this );
114
+			->getCheckResultsRenderer($this->getLanguage(), $this);
115 115
 
116 116
 		$this->getResult()->addValue(
117 117
 			null,
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 				)
126 126
 			)->getArray()
127 127
 		);
128
-		$this->resultBuilder->markSuccess( 1 );
128
+		$this->resultBuilder->markSuccess(1);
129 129
 	}
130 130
 
131 131
 	/**
@@ -133,24 +133,24 @@  discard block
 block discarded – undo
133 133
 	 *
134 134
 	 * @return EntityId[]
135 135
 	 */
136
-	private function parseEntityIds( array $params ): array {
136
+	private function parseEntityIds(array $params): array {
137 137
 		$ids = $params[self::PARAM_ID];
138 138
 
139
-		if ( $ids === null ) {
139
+		if ($ids === null) {
140 140
 			return [];
141
-		} elseif ( $ids === [] ) {
141
+		} elseif ($ids === []) {
142 142
 			$this->errorReporter->dieError(
143
-				'If ' . self::PARAM_ID . ' is specified, it must be nonempty.', 'no-data' );
143
+				'If '.self::PARAM_ID.' is specified, it must be nonempty.', 'no-data' );
144 144
 		}
145 145
 
146
-		return array_map( function ( $id ) {
146
+		return array_map(function($id) {
147 147
 			try {
148
-				return $this->entityIdParser->parse( $id );
149
-			} catch ( EntityIdParsingException $e ) {
148
+				return $this->entityIdParser->parse($id);
149
+			} catch (EntityIdParsingException $e) {
150 150
 				$this->errorReporter->dieError(
151
-					"Invalid id: $id", 'invalid-entity-id', 0, [ self::PARAM_ID => $id ] );
151
+					"Invalid id: $id", 'invalid-entity-id', 0, [self::PARAM_ID => $id] );
152 152
 			}
153
-		}, $ids );
153
+		}, $ids);
154 154
 	}
155 155
 
156 156
 	/**
@@ -158,35 +158,35 @@  discard block
 block discarded – undo
158 158
 	 *
159 159
 	 * @return string[]
160 160
 	 */
161
-	private function parseClaimIds( array $params ): array {
161
+	private function parseClaimIds(array $params): array {
162 162
 		$ids = $params[self::PARAM_CLAIM_ID];
163 163
 
164
-		if ( $ids === null ) {
164
+		if ($ids === null) {
165 165
 			return [];
166
-		} elseif ( $ids === [] ) {
166
+		} elseif ($ids === []) {
167 167
 			$this->errorReporter->dieError(
168
-				'If ' . self::PARAM_CLAIM_ID . ' is specified, it must be nonempty.', 'no-data' );
168
+				'If '.self::PARAM_CLAIM_ID.' is specified, it must be nonempty.', 'no-data' );
169 169
 		}
170 170
 
171
-		foreach ( $ids as $id ) {
172
-			if ( !$this->statementGuidValidator->validate( $id ) ) {
171
+		foreach ($ids as $id) {
172
+			if (!$this->statementGuidValidator->validate($id)) {
173 173
 				$this->errorReporter->dieError(
174
-					"Invalid claim id: $id", 'invalid-guid', 0, [ self::PARAM_CLAIM_ID => $id ] );
174
+					"Invalid claim id: $id", 'invalid-guid', 0, [self::PARAM_CLAIM_ID => $id] );
175 175
 			}
176 176
 		}
177 177
 
178 178
 		return $ids;
179 179
 	}
180 180
 
181
-	private function validateParameters( array $params ): void {
182
-		if ( $params[self::PARAM_CONSTRAINT_ID] !== null
183
-			 && empty( $params[self::PARAM_CONSTRAINT_ID] )
181
+	private function validateParameters(array $params): void {
182
+		if ($params[self::PARAM_CONSTRAINT_ID] !== null
183
+			 && empty($params[self::PARAM_CONSTRAINT_ID])
184 184
 		) {
185 185
 			$paramConstraintId = self::PARAM_CONSTRAINT_ID;
186 186
 			$this->errorReporter->dieError(
187 187
 				"If $paramConstraintId is specified, it must be nonempty.", 'no-data' );
188 188
 		}
189
-		if ( $params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null ) {
189
+		if ($params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null) {
190 190
 			$paramId = self::PARAM_ID;
191 191
 			$paramClaimId = self::PARAM_CLAIM_ID;
192 192
 			$this->errorReporter->dieError(
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 				],
228 228
 				ParamValidator::PARAM_ISMULTI => true,
229 229
 				ParamValidator::PARAM_ALL => true,
230
-				ParamValidator::PARAM_DEFAULT => implode( '|', CachingResultsSource::CACHED_STATUSES ),
230
+				ParamValidator::PARAM_DEFAULT => implode('|', CachingResultsSource::CACHED_STATUSES),
231 231
 				ApiBase::PARAM_HELP_MSG_PER_VALUE => [],
232 232
 			],
233 233
 		];
Please login to merge, or discard this patch.