Completed
Push — master ( 78a9b5...d0b390 )
by
unknown
02:29 queued 15s
created
src/ConstraintRepository.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -19,23 +19,23 @@  discard block
 block discarded – undo
19 19
 	 *
20 20
 	 * @return Constraint[]
21 21
 	 */
22
-	public function queryConstraintsForProperty( PropertyId $propertyId ) {
23
-		$db = wfGetDB( DB_REPLICA );
22
+	public function queryConstraintsForProperty(PropertyId $propertyId) {
23
+		$db = wfGetDB(DB_REPLICA);
24 24
 
25 25
 		$results = $db->select(
26 26
 			'wbqc_constraints',
27 27
 			'*',
28
-			[ 'pid' => $propertyId->getNumericId() ]
28
+			['pid' => $propertyId->getNumericId()]
29 29
 		);
30 30
 
31
-		return $this->convertToConstraints( $results );
31
+		return $this->convertToConstraints($results);
32 32
 	}
33 33
 
34
-	private function encodeConstraintParameters( array $constraintParameters ) {
35
-		$json = json_encode( $constraintParameters, JSON_FORCE_OBJECT );
34
+	private function encodeConstraintParameters(array $constraintParameters) {
35
+		$json = json_encode($constraintParameters, JSON_FORCE_OBJECT);
36 36
 
37
-		if ( strlen( $json ) > 50000 ) {
38
-			$json = json_encode( [ '@error' => [ 'toolong' => true ] ] );
37
+		if (strlen($json) > 50000) {
38
+			$json = json_encode(['@error' => ['toolong' => true]]);
39 39
 		}
40 40
 
41 41
 		return $json;
@@ -47,21 +47,21 @@  discard block
 block discarded – undo
47 47
 	 * @throws DBUnexpectedError
48 48
 	 * @return bool
49 49
 	 */
50
-	public function insertBatch( array $constraints ) {
50
+	public function insertBatch(array $constraints) {
51 51
 		$accumulator = array_map(
52
-			function ( Constraint $constraint ) {
52
+			function(Constraint $constraint) {
53 53
 				return [
54 54
 					'constraint_guid' => $constraint->getConstraintId(),
55 55
 					'pid' => $constraint->getPropertyId()->getNumericId(),
56 56
 					'constraint_type_qid' => $constraint->getConstraintTypeItemId(),
57
-					'constraint_parameters' => $this->encodeConstraintParameters( $constraint->getConstraintParameters() )
57
+					'constraint_parameters' => $this->encodeConstraintParameters($constraint->getConstraintParameters())
58 58
 				];
59 59
 			},
60 60
 			$constraints
61 61
 		);
62 62
 
63
-		$db = wfGetDB( DB_MASTER );
64
-		return $db->insert( 'wbqc_constraints', $accumulator );
63
+		$db = wfGetDB(DB_MASTER);
64
+		return $db->insert('wbqc_constraints', $accumulator);
65 65
 	}
66 66
 
67 67
 	/**
@@ -69,13 +69,13 @@  discard block
 block discarded – undo
69 69
 	 *
70 70
 	 * @return string[]
71 71
 	 */
72
-	private function uuidPattern( LikeMatch $any ) {
72
+	private function uuidPattern(LikeMatch $any) {
73 73
 		return array_merge(
74
-			array_fill( 0, 8, $any ), [ '-' ],
75
-			array_fill( 0, 4, $any ), [ '-' ],
76
-			array_fill( 0, 4, $any ), [ '-' ],
77
-			array_fill( 0, 4, $any ), [ '-' ],
78
-			array_fill( 0, 12, $any )
74
+			array_fill(0, 8, $any), ['-'],
75
+			array_fill(0, 4, $any), ['-'],
76
+			array_fill(0, 4, $any), ['-'],
77
+			array_fill(0, 4, $any), ['-'],
78
+			array_fill(0, 12, $any)
79 79
 		);
80 80
 	}
81 81
 
@@ -87,14 +87,14 @@  discard block
 block discarded – undo
87 87
 	 *
88 88
 	 * @throws DBUnexpectedError
89 89
 	 */
90
-	public function deleteForPropertyWhereConstraintIdIsStatementId( PropertyId $propertyId ) {
91
-		$db = wfGetDB( DB_MASTER );
90
+	public function deleteForPropertyWhereConstraintIdIsStatementId(PropertyId $propertyId) {
91
+		$db = wfGetDB(DB_MASTER);
92 92
 		$db->delete(
93 93
 			'wbqc_constraints',
94 94
 			[
95 95
 				'pid' => $propertyId->getNumericId(),
96 96
 				// AND constraint_guid LIKE %$________-____-____-____-____________
97
-				'constraint_guid ' . $db->buildLike( array_merge( [ $db->anyString(), '$' ], $this->uuidPattern( $db->anyChar() ) ) )
97
+				'constraint_guid '.$db->buildLike(array_merge([$db->anyString(), '$'], $this->uuidPattern($db->anyChar())))
98 98
 			]
99 99
 		);
100 100
 	}
@@ -104,26 +104,26 @@  discard block
 block discarded – undo
104 104
 	 *
105 105
 	 * @return Constraint[]
106 106
 	 */
107
-	private function convertToConstraints( IResultWrapper $results ) {
107
+	private function convertToConstraints(IResultWrapper $results) {
108 108
 		$constraints = [];
109
-		foreach ( $results as $result ) {
109
+		foreach ($results as $result) {
110 110
 			$constraintTypeItemId = $result->constraint_type_qid;
111
-			$constraintParameters = json_decode( $result->constraint_parameters, true );
111
+			$constraintParameters = json_decode($result->constraint_parameters, true);
112 112
 
113
-			if ( $constraintParameters === null ) {
113
+			if ($constraintParameters === null) {
114 114
 				// T171295
115
-				LoggerFactory::getInstance( 'WikibaseQualityConstraints' )
116
-					->warning( 'Constraint {constraintId} has invalid constraint parameters.', [
115
+				LoggerFactory::getInstance('WikibaseQualityConstraints')
116
+					->warning('Constraint {constraintId} has invalid constraint parameters.', [
117 117
 						'method' => __METHOD__,
118 118
 						'constraintId' => $result->constraint_guid,
119 119
 						'constraintParameters' => $result->constraint_parameters,
120
-					] );
121
-				$constraintParameters = [ '@error' => [ /* unknown */ ] ];
120
+					]);
121
+				$constraintParameters = ['@error' => [/* unknown */]];
122 122
 			}
123 123
 
124 124
 			$constraints[] = new Constraint(
125 125
 				$result->constraint_guid,
126
-				PropertyId::newFromNumber( $result->pid ),
126
+				PropertyId::newFromNumber($result->pid),
127 127
 				$constraintTypeItemId,
128 128
 				$constraintParameters
129 129
 			);
Please login to merge, or discard this patch.