Completed
Push — master ( 37682c...11e3bd )
by
unknown
02:09
created
src/Api/CheckingResultsBuilder.php 1 patch
Spacing   +28 added lines, -29 removed lines patch added patch discarded remove patch
@@ -84,65 +84,64 @@  discard block
 block discarded – undo
84 84
 	) {
85 85
 		$response = [];
86 86
 		$metadatas = [];
87
-		$statusesFlipped = array_flip( $statuses );
88
-		foreach ( $entityIds as $entityId ) {
87
+		$statusesFlipped = array_flip($statuses);
88
+		foreach ($entityIds as $entityId) {
89 89
 			$results = $this->delegatingConstraintChecker->checkAgainstConstraintsOnEntityId(
90 90
 				$entityId,
91 91
 				$constraintIds,
92
-				[ $this, 'defaultResults' ]
92
+				[$this, 'defaultResults']
93 93
 			);
94
-			foreach ( $results as $result ) {
94
+			foreach ($results as $result) {
95 95
 				$metadatas[] = $result->getMetadata();
96
-				if ( $this->statusSelected( $statusesFlipped, $result ) ) {
97
-					$resultArray = $this->checkResultToArray( $result );
98
-					$result->getContextCursor()->storeCheckResultInArray( $resultArray, $response );
96
+				if ($this->statusSelected($statusesFlipped, $result)) {
97
+					$resultArray = $this->checkResultToArray($result);
98
+					$result->getContextCursor()->storeCheckResultInArray($resultArray, $response);
99 99
 				}
100 100
 			}
101 101
 		}
102
-		foreach ( $claimIds as $claimId ) {
102
+		foreach ($claimIds as $claimId) {
103 103
 			$results = $this->delegatingConstraintChecker->checkAgainstConstraintsOnClaimId(
104 104
 				$claimId,
105 105
 				$constraintIds,
106
-				[ $this, 'defaultResults' ]
106
+				[$this, 'defaultResults']
107 107
 			);
108
-			foreach ( $results as $result ) {
108
+			foreach ($results as $result) {
109 109
 				$metadatas[] = $result->getMetadata();
110
-				if ( $this->statusSelected( $statusesFlipped, $result ) ) {
111
-					$resultArray = $this->checkResultToArray( $result );
112
-					$result->getContextCursor()->storeCheckResultInArray( $resultArray, $response );
110
+				if ($this->statusSelected($statusesFlipped, $result)) {
111
+					$resultArray = $this->checkResultToArray($result);
112
+					$result->getContextCursor()->storeCheckResultInArray($resultArray, $response);
113 113
 				}
114 114
 			}
115 115
 		}
116 116
 		return new CachedCheckConstraintsResponse(
117 117
 			$response,
118
-			Metadata::merge( $metadatas )
118
+			Metadata::merge($metadatas)
119 119
 		);
120 120
 	}
121 121
 
122
-	public function defaultResults( Context $context ) {
122
+	public function defaultResults(Context $context) {
123 123
 		return $context->getType() === Context::TYPE_STATEMENT ?
124
-			[ new NullResult( $context ) ] :
125
-			[];
124
+			[new NullResult($context)] : [];
126 125
 	}
127 126
 
128
-	public function statusSelected( array $statusesFlipped, CheckResult $result ) {
129
-		return array_key_exists( $result->getStatus(), $statusesFlipped ) ||
127
+	public function statusSelected(array $statusesFlipped, CheckResult $result) {
128
+		return array_key_exists($result->getStatus(), $statusesFlipped) ||
130 129
 			$result instanceof NullResult;
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
 
138 137
 		$constraintId = $checkResult->getConstraint()->getConstraintId();
139 138
 		$typeItemId = $checkResult->getConstraint()->getConstraintTypeItemId();
140
-		$constraintPropertyId = new PropertyId( $checkResult->getContextCursor()->getSnakPropertyId() );
139
+		$constraintPropertyId = new PropertyId($checkResult->getContextCursor()->getSnakPropertyId());
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,
@@ -158,14 +157,14 @@  discard block
 block discarded – undo
158 157
 			'constraint' => $constraint
159 158
 		];
160 159
 		$message = $checkResult->getMessage();
161
-		if ( $message ) {
162
-			$result['message-html'] = $this->violationMessageRenderer->render( $message );
160
+		if ($message) {
161
+			$result['message-html'] = $this->violationMessageRenderer->render($message);
163 162
 		}
164
-		if ( $checkResult->getContextCursor()->getType() === Context::TYPE_STATEMENT ) {
163
+		if ($checkResult->getContextCursor()->getType() === Context::TYPE_STATEMENT) {
165 164
 			$result['claim'] = $checkResult->getContextCursor()->getStatementGuid();
166 165
 		}
167 166
 		$cachingMetadataArray = $checkResult->getMetadata()->getCachingMetadata()->toArray();
168
-		if ( $cachingMetadataArray !== null ) {
167
+		if ($cachingMetadataArray !== null) {
169 168
 			$result['cached'] = $cachingMetadataArray;
170 169
 		}
171 170
 
Please login to merge, or discard this patch.