Completed
Push — master ( df640b...26761f )
by
unknown
03:36
created
src/Api/CheckingResultsBuilder.php 1 patch
Spacing   +30 added lines, -31 removed lines patch added patch discarded remove patch
@@ -83,55 +83,54 @@  discard block
 block discarded – undo
83 83
 	) {
84 84
 		$response = [];
85 85
 		$metadatas = [];
86
-		$statusesFlipped = array_flip( $statuses );
87
-		foreach ( $entityIds as $entityId ) {
86
+		$statusesFlipped = array_flip($statuses);
87
+		foreach ($entityIds as $entityId) {
88 88
 			$results = $this->delegatingConstraintChecker->checkAgainstConstraintsOnEntityId(
89 89
 				$entityId,
90 90
 				$constraintIds,
91
-				[ $this, 'defaultResults' ]
91
+				[$this, 'defaultResults']
92 92
 			);
93 93
 			/** @var CheckResult[] $results */
94
-			$results = array_filter( $results, $this->statusSelected( $statusesFlipped ) );
95
-			foreach ( $results as $result ) {
94
+			$results = array_filter($results, $this->statusSelected($statusesFlipped));
95
+			foreach ($results as $result) {
96 96
 				$metadatas[] = $result->getMetadata();
97
-				$resultArray = $this->checkResultToArray( $result );
98
-				$result->getContext()->storeCheckResultInArray( $resultArray, $response );
97
+				$resultArray = $this->checkResultToArray($result);
98
+				$result->getContext()->storeCheckResultInArray($resultArray, $response);
99 99
 			}
100 100
 		}
101
-		foreach ( $claimIds as $claimId ) {
101
+		foreach ($claimIds as $claimId) {
102 102
 			$results = $this->delegatingConstraintChecker->checkAgainstConstraintsOnClaimId(
103 103
 				$claimId,
104 104
 				$constraintIds,
105
-				[ $this, 'defaultResults' ]
105
+				[$this, 'defaultResults']
106 106
 			);
107
-			$results = array_filter( $results, $this->statusSelected( $statusesFlipped ) );
108
-			foreach ( $results as $result ) {
107
+			$results = array_filter($results, $this->statusSelected($statusesFlipped));
108
+			foreach ($results as $result) {
109 109
 				$metadatas[] = $result->getMetadata();
110
-				$resultArray = $this->checkResultToArray( $result );
111
-				$result->getContext()->storeCheckResultInArray( $resultArray, $response );
110
+				$resultArray = $this->checkResultToArray($result);
111
+				$result->getContext()->storeCheckResultInArray($resultArray, $response);
112 112
 			}
113 113
 		}
114 114
 		return new CachedCheckConstraintsResponse(
115 115
 			$response,
116
-			Metadata::merge( $metadatas )
116
+			Metadata::merge($metadatas)
117 117
 		);
118 118
 	}
119 119
 
120
-	public function defaultResults( Context $context ) {
120
+	public function defaultResults(Context $context) {
121 121
 		return $context->getType() === Context::TYPE_STATEMENT ?
122
-			[ new NullResult( $context ) ] :
123
-			[];
122
+			[new NullResult($context)] : [];
124 123
 	}
125 124
 
126
-	public function statusSelected( array $statusesFlipped ) {
127
-		return function( CheckResult $result ) use ( $statusesFlipped ) {
128
-			return array_key_exists( $result->getStatus(), $statusesFlipped ) ||
125
+	public function statusSelected(array $statusesFlipped) {
126
+		return function(CheckResult $result) use ($statusesFlipped) {
127
+			return array_key_exists($result->getStatus(), $statusesFlipped) ||
129 128
 				$result instanceof NullResult;
130 129
 		};
131 130
 	}
132 131
 
133
-	public function checkResultToArray( CheckResult $checkResult ) {
134
-		if ( $checkResult instanceof NullResult ) {
132
+	public function checkResultToArray(CheckResult $checkResult) {
133
+		if ($checkResult instanceof NullResult) {
135 134
 			return null;
136 135
 		}
137 136
 
@@ -139,10 +138,10 @@  discard block
 block discarded – undo
139 138
 		$typeItemId = $checkResult->getConstraint()->getConstraintTypeItemId();
140 139
 		$constraintPropertyId = $checkResult->getContext()->getSnak()->getPropertyId();
141 140
 
142
-		$title = $this->entityTitleLookup->getTitleForId( $constraintPropertyId );
143
-		$typeLabel = $this->entityIdLabelFormatter->formatEntityId( new ItemId( $typeItemId ) );
141
+		$title = $this->entityTitleLookup->getTitleForId($constraintPropertyId);
142
+		$typeLabel = $this->entityIdLabelFormatter->formatEntityId(new ItemId($typeItemId));
144 143
 		// TODO link to the statement when possible (T169224)
145
-		$link = $title->getFullURL() . '#' . $this->config->get( 'WBQualityConstraintsPropertyConstraintId' );
144
+		$link = $title->getFullURL().'#'.$this->config->get('WBQualityConstraintsPropertyConstraintId');
146 145
 
147 146
 		$constraint = [
148 147
 			'id' => $constraintId,
@@ -151,11 +150,11 @@  discard block
 block discarded – undo
151 150
 			'link' => $link,
152 151
 			'discussLink' => $title->getTalkPage()->getFullURL(),
153 152
 		];
154
-		if ( $this->config->get( 'WBQualityConstraintsIncludeDetailInApi' ) ) {
153
+		if ($this->config->get('WBQualityConstraintsIncludeDetailInApi')) {
155 154
 			$parameters = $checkResult->getParameters();
156 155
 			$constraint += [
157 156
 				'detail' => $parameters,
158
-				'detailHTML' => $this->constraintParameterRenderer->formatParameters( $parameters ),
157
+				'detailHTML' => $this->constraintParameterRenderer->formatParameters($parameters),
159 158
 			];
160 159
 		}
161 160
 
@@ -165,14 +164,14 @@  discard block
 block discarded – undo
165 164
 			'constraint' => $constraint
166 165
 		];
167 166
 		$message = $checkResult->getMessage();
168
-		if ( $message ) {
169
-			$result['message-html'] = $this->violationMessageRenderer->render( $message );
167
+		if ($message) {
168
+			$result['message-html'] = $this->violationMessageRenderer->render($message);
170 169
 		}
171
-		if ( $checkResult->getContext()->getType() === Context::TYPE_STATEMENT ) {
170
+		if ($checkResult->getContext()->getType() === Context::TYPE_STATEMENT) {
172 171
 			$result['claim'] = $checkResult->getContext()->getSnakStatement()->getGuid();
173 172
 		}
174 173
 		$cachingMetadataArray = $checkResult->getMetadata()->getCachingMetadata()->toArray();
175
-		if ( $cachingMetadataArray !== null ) {
174
+		if ($cachingMetadataArray !== null) {
176 175
 			$result['cached'] = $cachingMetadataArray;
177 176
 		}
178 177
 
Please login to merge, or discard this patch.