Completed
Push — master ( 353732...0b88dd )
by
unknown
26:16
created
src/ConstraintCheck/Helper/LoggingHelper.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
 		$this->dataFactory = $dataFactory;
47 47
 		$this->logger = $logger;
48 48
 		$this->constraintCheckDurationLimits = [
49
-			'info' => $config->get( 'WBQualityConstraintsCheckDurationInfoSeconds' ),
50
-			'warning' => $config->get( 'WBQualityConstraintsCheckDurationWarningSeconds' ),
49
+			'info' => $config->get('WBQualityConstraintsCheckDurationInfoSeconds'),
50
+			'warning' => $config->get('WBQualityConstraintsCheckDurationWarningSeconds'),
51 51
 		];
52 52
 	}
53 53
 
@@ -73,39 +73,39 @@  discard block
 block discarded – undo
73 73
 		$durationSeconds,
74 74
 		$method
75 75
 	) {
76
-		$constraintCheckerClassShortName = substr( strrchr( $constraintCheckerClass, '\\' ), 1 );
76
+		$constraintCheckerClassShortName = substr(strrchr($constraintCheckerClass, '\\'), 1);
77 77
 		$constraintTypeItemId = $constraint->getConstraintTypeItemId();
78 78
 
79 79
 		$this->dataFactory->timing(
80
-			'wikibase.quality.constraints.check.timing.' .
81
-				$constraintTypeItemId . '-' .
80
+			'wikibase.quality.constraints.check.timing.'.
81
+				$constraintTypeItemId.'-'.
82 82
 				$constraintCheckerClassShortName,
83 83
 			$durationSeconds * 1000
84 84
 		);
85 85
 
86 86
 		// find the longest limit (and associated log level) that the duration exceeds
87
-		foreach ( $this->constraintCheckDurationLimits as $level => $limit ) {
87
+		foreach ($this->constraintCheckDurationLimits as $level => $limit) {
88 88
 			if (
89 89
 				// duration exceeds this limit
90
-				isset( $limit ) && $durationSeconds > $limit &&
90
+				isset($limit) && $durationSeconds > $limit &&
91 91
 				// this limit is longer than previous longest limit
92
-				( !isset( $limitSeconds ) || $limit > $limitSeconds )
92
+				(!isset($limitSeconds) || $limit > $limitSeconds)
93 93
 			) {
94 94
 				$limitSeconds = $limit;
95 95
 				$logLevel = $level;
96 96
 			}
97 97
 		}
98 98
 
99
-		if ( !isset( $limitSeconds ) ) {
99
+		if (!isset($limitSeconds)) {
100 100
 			return;
101 101
 		}
102
-		if ( $context->getType() !== Context::TYPE_STATEMENT ) {
102
+		if ($context->getType() !== Context::TYPE_STATEMENT) {
103 103
 			// TODO log less details but still log something
104 104
 			return;
105 105
 		}
106 106
 
107 107
 		$resultMessage = $result->getMessage();
108
-		if ( $resultMessage !== null ) {
108
+		if ($resultMessage !== null) {
109 109
 			$resultMessageKey = $resultMessage->getMessageKey();
110 110
 		} else {
111 111
 			$resultMessageKey = null;
@@ -113,8 +113,8 @@  discard block
 block discarded – undo
113 113
 
114 114
 		$this->logger->log(
115 115
 			$logLevel,
116
-			'Constraint check with {constraintCheckerClassShortName} ' .
117
-			'took longer than {limitSeconds} second(s) ' .
116
+			'Constraint check with {constraintCheckerClassShortName} '.
117
+			'took longer than {limitSeconds} second(s) '.
118 118
 			'(duration: {durationSeconds} seconds).',
119 119
 			[
120 120
 				'method' => $method,
@@ -124,13 +124,13 @@  discard block
 block discarded – undo
124 124
 				'constraintId' => $constraint->getConstraintId(),
125 125
 				'constraintPropertyId' => $constraint->getPropertyId()->getSerialization(),
126 126
 				'constraintTypeItemId' => $constraintTypeItemId,
127
-				'constraintParameters' => json_encode( $constraint->getConstraintParameters() ),
127
+				'constraintParameters' => json_encode($constraint->getConstraintParameters()),
128 128
 				'constraintCheckerClass' => $constraintCheckerClass,
129 129
 				'constraintCheckerClassShortName' => $constraintCheckerClassShortName,
130 130
 				'entityId' => $context->getEntity()->getId()->getSerialization(),
131 131
 				'statementGuid' => $context->getSnakStatement()->getGuid(),
132 132
 				'resultStatus' => $result->getStatus(),
133
-				'resultParameters' => json_encode( $result->getParameters() ),
133
+				'resultParameters' => json_encode($result->getParameters()),
134 134
 				'resultMessage' => $resultMessageKey,
135 135
 			]
136 136
 		);
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 *
142 142
 	 * @param EntityId $entityId
143 143
 	 */
144
-	public function logCheckConstraintsCacheHit( EntityId $entityId ) {
144
+	public function logCheckConstraintsCacheHit(EntityId $entityId) {
145 145
 		$this->dataFactory->increment(
146 146
 			'wikibase.quality.constraints.cache.entity.hit'
147 147
 		);
@@ -152,10 +152,10 @@  discard block
 block discarded – undo
152 152
 	 *
153 153
 	 * @param EntityId[] $entityIds
154 154
 	 */
155
-	public function logCheckConstraintsCacheMisses( array $entityIds ) {
155
+	public function logCheckConstraintsCacheMisses(array $entityIds) {
156 156
 		$this->dataFactory->updateCount(
157 157
 			'wikibase.quality.constraints.cache.entity.miss',
158
-			count( $entityIds )
158
+			count($entityIds)
159 159
 		);
160 160
 	}
161 161
 
@@ -182,17 +182,17 @@  discard block
 block discarded – undo
182 182
 	 * @param EntityId[] $entityIds
183 183
 	 * @param int $maxRevisionIds
184 184
 	 */
185
-	public function logHugeDependencyMetadata( array $entityIds, $maxRevisionIds ) {
185
+	public function logHugeDependencyMetadata(array $entityIds, $maxRevisionIds) {
186 186
 		$this->logger->log(
187 187
 			'warning',
188
-			'Dependency metadata for constraint check result has huge set of entity IDs ' .
189
-			'(count ' . count( $entityIds ) . ', limit ' . $maxRevisionIds . '); ' .
188
+			'Dependency metadata for constraint check result has huge set of entity IDs '.
189
+			'(count '.count($entityIds).', limit '.$maxRevisionIds.'); '.
190 190
 			'caching disabled for this check result.',
191 191
 			[
192 192
 				'loggingMethod' => __METHOD__,
193 193
 				'entityIds' => json_encode(
194 194
 					array_map(
195
-						function ( EntityId $entityId ) {
195
+						function(EntityId $entityId) {
196 196
 							return $entityId->getSerialization();
197 197
 						},
198 198
 						$entityIds
Please login to merge, or discard this patch.