@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | * |
| 16 | 16 | * @throws DBUnexpectedError |
| 17 | 17 | */ |
| 18 | - public function insertBatch( array $constraints ); |
|
| 18 | + public function insertBatch(array $constraints); |
|
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | 21 | * Delete all constraints for the property ID. |
@@ -24,6 +24,6 @@ discard block |
||
| 24 | 24 | * |
| 25 | 25 | * @throws DBUnexpectedError |
| 26 | 26 | */ |
| 27 | - public function deleteForProperty( NumericPropertyId $propertyId ); |
|
| 27 | + public function deleteForProperty(NumericPropertyId $propertyId); |
|
| 28 | 28 | |
| 29 | 29 | } |
@@ -24,16 +24,16 @@ discard block |
||
| 24 | 24 | * then using the main DBLoadBalancer service may be incorrect. |
| 25 | 25 | * @param string|false $dbName Database name ($domain for ILoadBalancer methods). |
| 26 | 26 | */ |
| 27 | - public function __construct( ILoadBalancer $lb, $dbName ) { |
|
| 27 | + public function __construct(ILoadBalancer $lb, $dbName) { |
|
| 28 | 28 | $this->lb = $lb; |
| 29 | 29 | $this->dbName = $dbName; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - private function encodeConstraintParameters( array $constraintParameters ) { |
|
| 33 | - $json = json_encode( $constraintParameters, JSON_FORCE_OBJECT ); |
|
| 32 | + private function encodeConstraintParameters(array $constraintParameters) { |
|
| 33 | + $json = json_encode($constraintParameters, JSON_FORCE_OBJECT); |
|
| 34 | 34 | |
| 35 | - if ( strlen( $json ) > 50000 ) { |
|
| 36 | - $json = json_encode( [ '@error' => [ 'toolong' => true ] ] ); |
|
| 35 | + if (strlen($json) > 50000) { |
|
| 36 | + $json = json_encode(['@error' => ['toolong' => true]]); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | return $json; |
@@ -44,28 +44,28 @@ discard block |
||
| 44 | 44 | * |
| 45 | 45 | * @throws DBUnexpectedError |
| 46 | 46 | */ |
| 47 | - public function insertBatch( array $constraints ) { |
|
| 48 | - if ( !$constraints ) { |
|
| 47 | + public function insertBatch(array $constraints) { |
|
| 48 | + if (!$constraints) { |
|
| 49 | 49 | return; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | $accumulator = array_map( |
| 53 | - function ( Constraint $constraint ) { |
|
| 53 | + function(Constraint $constraint) { |
|
| 54 | 54 | return [ |
| 55 | 55 | 'constraint_guid' => $constraint->getConstraintId(), |
| 56 | 56 | 'pid' => $constraint->getPropertyId()->getNumericId(), |
| 57 | 57 | 'constraint_type_qid' => $constraint->getConstraintTypeItemId(), |
| 58 | - 'constraint_parameters' => $this->encodeConstraintParameters( $constraint->getConstraintParameters() ), |
|
| 58 | + 'constraint_parameters' => $this->encodeConstraintParameters($constraint->getConstraintParameters()), |
|
| 59 | 59 | ]; |
| 60 | 60 | }, |
| 61 | 61 | $constraints |
| 62 | 62 | ); |
| 63 | 63 | |
| 64 | - $dbw = $this->lb->getConnection( ILoadBalancer::DB_PRIMARY, [], $this->dbName ); |
|
| 64 | + $dbw = $this->lb->getConnection(ILoadBalancer::DB_PRIMARY, [], $this->dbName); |
|
| 65 | 65 | $dbw->newInsertQueryBuilder() |
| 66 | - ->insertInto( 'wbqc_constraints' ) |
|
| 67 | - ->rows( $accumulator ) |
|
| 68 | - ->caller( __METHOD__ ) |
|
| 66 | + ->insertInto('wbqc_constraints') |
|
| 67 | + ->rows($accumulator) |
|
| 68 | + ->caller(__METHOD__) |
|
| 69 | 69 | ->execute(); |
| 70 | 70 | } |
| 71 | 71 | |
@@ -76,14 +76,14 @@ discard block |
||
| 76 | 76 | * |
| 77 | 77 | * @throws DBUnexpectedError |
| 78 | 78 | */ |
| 79 | - public function deleteForProperty( NumericPropertyId $propertyId ) { |
|
| 80 | - $dbw = $this->lb->getConnection( ILoadBalancer::DB_PRIMARY, [], $this->dbName ); |
|
| 79 | + public function deleteForProperty(NumericPropertyId $propertyId) { |
|
| 80 | + $dbw = $this->lb->getConnection(ILoadBalancer::DB_PRIMARY, [], $this->dbName); |
|
| 81 | 81 | $dbw->newDeleteQueryBuilder() |
| 82 | - ->deleteFrom( 'wbqc_constraints' ) |
|
| 83 | - ->where( [ |
|
| 82 | + ->deleteFrom('wbqc_constraints') |
|
| 83 | + ->where([ |
|
| 84 | 84 | 'pid' => $propertyId->getNumericId(), |
| 85 | - ] ) |
|
| 86 | - ->caller( __METHOD__ ) |
|
| 85 | + ]) |
|
| 86 | + ->caller(__METHOD__) |
|
| 87 | 87 | ->execute(); |
| 88 | 88 | } |
| 89 | 89 | |