@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | { |
| 40 | 40 | $this->constraints[] = new CountConstraint($min, $max, $weight); |
| 41 | 41 | |
| 42 | - StableSort::usort($this->constraints, static function (CountConstraint $a, CountConstraint $b): int { |
|
| 42 | + StableSort::usort($this->constraints, static function(CountConstraint $a, CountConstraint $b): int { |
|
| 43 | 43 | return $b->getWeight() <=> $a->getWeight(); |
| 44 | 44 | }); |
| 45 | 45 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | public function test($password, ?int $weight = null): bool |
| 57 | 57 | { |
| 58 | - $count = $this->getCount((string)$password); |
|
| 58 | + $count = $this->getCount((string) $password); |
|
| 59 | 59 | $constraint = $this->getViolation($count, $weight); |
| 60 | 60 | |
| 61 | 61 | return $constraint === null; |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | */ |
| 71 | 71 | public function validate($password, TranslatorInterface $translator): ?ValidationError |
| 72 | 72 | { |
| 73 | - $count = $this->getCount((string)$password); |
|
| 73 | + $count = $this->getCount((string) $password); |
|
| 74 | 74 | $constraint = $this->getViolation($count); |
| 75 | 75 | |
| 76 | 76 | if ($constraint !== null) { |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | assert(count($passwordCharacters) === count($upperCaseCharacters)); |
| 118 | 118 | |
| 119 | 119 | $count = 0; |
| 120 | - for ($i = count($passwordCharacters) - 1; $i >= 0; --$i) { |
|
| 120 | + for ($i = count($passwordCharacters)-1; $i >= 0; --$i) { |
|
| 121 | 121 | if ($passwordCharacters[$i] !== $upperCaseCharacters[$i]) { |
| 122 | 122 | ++$count; |
| 123 | 123 | } |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | { |
| 149 | 149 | if ($constraint->getMax() === null) { |
| 150 | 150 | return $translator->trans( |
| 151 | - 'The password must contain at least one lower case letter.|' . |
|
| 151 | + 'The password must contain at least one lower case letter.|'. |
|
| 152 | 152 | 'The password must contain at least %count% lower case letters.', |
| 153 | 153 | ['%count%' => $constraint->getMin()] |
| 154 | 154 | ); |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | |
| 163 | 163 | if ($constraint->getMin() === 0) { |
| 164 | 164 | return $translator->trans( |
| 165 | - 'The password must contain at most one lower case letter.|' . |
|
| 165 | + 'The password must contain at most one lower case letter.|'. |
|
| 166 | 166 | 'The password must contain at most %count% lower case letters.', |
| 167 | 167 | ['%count%' => $constraint->getMax()] |
| 168 | 168 | ); |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | |
| 171 | 171 | if ($constraint->getMin() === $constraint->getMax()) { |
| 172 | 172 | return $translator->trans( |
| 173 | - 'The password must contain exactly one lower case letter.|' . |
|
| 173 | + 'The password must contain exactly one lower case letter.|'. |
|
| 174 | 174 | 'The password must contain exactly %count% lower case letters.', |
| 175 | 175 | ['%count%' => $constraint->getMin()] |
| 176 | 176 | ); |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | { |
| 40 | 40 | $this->constraints[] = new CountConstraint($min, $max, $weight); |
| 41 | 41 | |
| 42 | - StableSort::usort($this->constraints, static function (CountConstraint $a, CountConstraint $b): int { |
|
| 42 | + StableSort::usort($this->constraints, static function(CountConstraint $a, CountConstraint $b): int { |
|
| 43 | 43 | return $b->getWeight() <=> $a->getWeight(); |
| 44 | 44 | }); |
| 45 | 45 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | public function test($password, ?int $weight = null): bool |
| 57 | 57 | { |
| 58 | - $count = $this->getCount((string)$password); |
|
| 58 | + $count = $this->getCount((string) $password); |
|
| 59 | 59 | $constraint = $this->getViolation($count, $weight); |
| 60 | 60 | |
| 61 | 61 | return $constraint === null; |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | */ |
| 71 | 71 | public function validate($password, TranslatorInterface $translator): ?ValidationError |
| 72 | 72 | { |
| 73 | - $count = $this->getCount((string)$password); |
|
| 73 | + $count = $this->getCount((string) $password); |
|
| 74 | 74 | $constraint = $this->getViolation($count); |
| 75 | 75 | |
| 76 | 76 | if ($constraint !== null) { |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | { |
| 124 | 124 | if ($constraint->getMax() === null) { |
| 125 | 125 | return $translator->trans( |
| 126 | - 'The password must contain at least one character.|' . |
|
| 126 | + 'The password must contain at least one character.|'. |
|
| 127 | 127 | 'The password must contain at least %count% characters.', |
| 128 | 128 | ['%count%' => $constraint->getMin()] |
| 129 | 129 | ); |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | |
| 138 | 138 | if ($constraint->getMin() === 0) { |
| 139 | 139 | return $translator->trans( |
| 140 | - 'The password must contain at most one character.|' . |
|
| 140 | + 'The password must contain at most one character.|'. |
|
| 141 | 141 | 'The password must contain at most %count% characters.', |
| 142 | 142 | ['%count%' => $constraint->getMax()] |
| 143 | 143 | ); |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | |
| 146 | 146 | if ($constraint->getMin() === $constraint->getMax()) { |
| 147 | 147 | return $translator->trans( |
| 148 | - 'The password must contain exactly one character.|' . |
|
| 148 | + 'The password must contain exactly one character.|'. |
|
| 149 | 149 | 'The password must contain exactly %count% characters.', |
| 150 | 150 | ['%count%' => $constraint->getMin()] |
| 151 | 151 | ); |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | { |
| 52 | 52 | $this->constraints[] = new CountConstraint($min, $max, $weight); |
| 53 | 53 | |
| 54 | - StableSort::usort($this->constraints, static function (CountConstraint $a, CountConstraint $b): int { |
|
| 54 | + StableSort::usort($this->constraints, static function(CountConstraint $a, CountConstraint $b): int { |
|
| 55 | 55 | return $b->getWeight() <=> $a->getWeight(); |
| 56 | 56 | }); |
| 57 | 57 | |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | */ |
| 76 | 76 | public function test($password, ?int $weight = null): bool |
| 77 | 77 | { |
| 78 | - $count = $this->getCount((string)$password); |
|
| 78 | + $count = $this->getCount((string) $password); |
|
| 79 | 79 | $constraint = $this->getViolation($count, $weight); |
| 80 | 80 | |
| 81 | 81 | return $constraint === null; |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | */ |
| 91 | 91 | public function validate($password, TranslatorInterface $translator): ?ValidationError |
| 92 | 92 | { |
| 93 | - $count = $this->getCount((string)$password); |
|
| 93 | + $count = $this->getCount((string) $password); |
|
| 94 | 94 | $constraint = $this->getViolation($count); |
| 95 | 95 | |
| 96 | 96 | if ($constraint !== null) { |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | private function getCount(string $password): int |
| 132 | 132 | { |
| 133 | 133 | $escapedCharacters = preg_quote($this->characters); |
| 134 | - $count = preg_match_all('{[' . $escapedCharacters . ']}u', $password); |
|
| 134 | + $count = preg_match_all('{['.$escapedCharacters.']}u', $password); |
|
| 135 | 135 | assert($count !== false); |
| 136 | 136 | |
| 137 | 137 | return $count; |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | { |
| 40 | 40 | $this->constraints[] = new CountConstraint($min, $max, $weight); |
| 41 | 41 | |
| 42 | - StableSort::usort($this->constraints, static function (CountConstraint $a, CountConstraint $b): int { |
|
| 42 | + StableSort::usort($this->constraints, static function(CountConstraint $a, CountConstraint $b): int { |
|
| 43 | 43 | return $b->getWeight() <=> $a->getWeight(); |
| 44 | 44 | }); |
| 45 | 45 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | public function test($password, ?int $weight = null): bool |
| 57 | 57 | { |
| 58 | - $count = $this->getCount((string)$password); |
|
| 58 | + $count = $this->getCount((string) $password); |
|
| 59 | 59 | $constraint = $this->getViolation($count, $weight); |
| 60 | 60 | |
| 61 | 61 | return $constraint === null; |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | */ |
| 71 | 71 | public function validate($password, TranslatorInterface $translator): ?ValidationError |
| 72 | 72 | { |
| 73 | - $count = $this->getCount((string)$password); |
|
| 73 | + $count = $this->getCount((string) $password); |
|
| 74 | 74 | $constraint = $this->getViolation($count); |
| 75 | 75 | |
| 76 | 76 | if ($constraint !== null) { |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | assert(count($passwordCharacters) === count($lowerCaseCharacters)); |
| 118 | 118 | |
| 119 | 119 | $count = 0; |
| 120 | - for ($i = count($passwordCharacters) - 1; $i >= 0; --$i) { |
|
| 120 | + for ($i = count($passwordCharacters)-1; $i >= 0; --$i) { |
|
| 121 | 121 | if ($passwordCharacters[$i] !== $lowerCaseCharacters[$i]) { |
| 122 | 122 | ++$count; |
| 123 | 123 | } |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | { |
| 149 | 149 | if ($constraint->getMax() === null) { |
| 150 | 150 | return $translator->trans( |
| 151 | - 'The password must contain at least one upper case letter.|' . |
|
| 151 | + 'The password must contain at least one upper case letter.|'. |
|
| 152 | 152 | 'The password must contain at least %count% upper case letters.', |
| 153 | 153 | ['%count%' => $constraint->getMin()] |
| 154 | 154 | ); |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | |
| 163 | 163 | if ($constraint->getMin() === 0) { |
| 164 | 164 | return $translator->trans( |
| 165 | - 'The password must contain at most one upper case letter.|' . |
|
| 165 | + 'The password must contain at most one upper case letter.|'. |
|
| 166 | 166 | 'The password must contain at most %count% upper case letters.', |
| 167 | 167 | ['%count%' => $constraint->getMax()] |
| 168 | 168 | ); |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | |
| 171 | 171 | if ($constraint->getMin() === $constraint->getMax()) { |
| 172 | 172 | return $translator->trans( |
| 173 | - 'The password must contain exactly one upper case letter.|' . |
|
| 173 | + 'The password must contain exactly one upper case letter.|'. |
|
| 174 | 174 | 'The password must contain exactly %count% upper case letters.', |
| 175 | 175 | ['%count%' => $constraint->getMin()] |
| 176 | 176 | ); |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | { |
| 55 | 55 | $this->constraints[] = new CountConstraint($min, $max, $weight); |
| 56 | 56 | |
| 57 | - StableSort::usort($this->constraints, static function (CountConstraint $a, CountConstraint $b): int { |
|
| 57 | + StableSort::usort($this->constraints, static function(CountConstraint $a, CountConstraint $b): int { |
|
| 58 | 58 | return $b->getWeight() <=> $a->getWeight(); |
| 59 | 59 | }); |
| 60 | 60 | |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | */ |
| 108 | 108 | public function test($password, ?int $weight = null): bool |
| 109 | 109 | { |
| 110 | - $count = $this->getCount((string)$password); |
|
| 110 | + $count = $this->getCount((string) $password); |
|
| 111 | 111 | $constraint = $this->getViolation($count, $weight); |
| 112 | 112 | |
| 113 | 113 | return $constraint === null; |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | */ |
| 119 | 119 | public function validate($password, TranslatorInterface $translator): ?ValidationError |
| 120 | 120 | { |
| 121 | - $count = $this->getCount((string)$password); |
|
| 121 | + $count = $this->getCount((string) $password); |
|
| 122 | 122 | $constraint = $this->getViolation($count); |
| 123 | 123 | |
| 124 | 124 | if ($constraint !== null) { |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | |
| 166 | 166 | try { |
| 167 | 167 | $requestFactory = $this->getRequestFactory(); |
| 168 | - $request = $requestFactory->createRequest('GET', 'https://api.pwnedpasswords.com/range/' . $prefix); |
|
| 168 | + $request = $requestFactory->createRequest('GET', 'https://api.pwnedpasswords.com/range/'.$prefix); |
|
| 169 | 169 | |
| 170 | 170 | $client = $this->getClient(); |
| 171 | 171 | |
@@ -175,14 +175,14 @@ discard block |
||
| 175 | 175 | $lines = explode("\r\n", $contents); |
| 176 | 176 | foreach ($lines as $line) { |
| 177 | 177 | if (substr($line, 0, 35) === $suffix) { |
| 178 | - return (int)substr($line, 36); |
|
| 178 | + return (int) substr($line, 36); |
|
| 179 | 179 | } |
| 180 | 180 | } |
| 181 | 181 | return 0; |
| 182 | 182 | } catch (ClientExceptionInterface | RuntimeException $exception) { |
| 183 | 183 | throw new CouldNotUseRuleException( |
| 184 | 184 | $this, |
| 185 | - 'An error occurred while using the Have I Been Pwned? service: ' . $exception->getMessage(), |
|
| 185 | + 'An error occurred while using the Have I Been Pwned? service: '.$exception->getMessage(), |
|
| 186 | 186 | $exception |
| 187 | 187 | ); |
| 188 | 188 | } |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | { |
| 199 | 199 | if ($constraint->getMax() === null) { |
| 200 | 200 | return $translator->trans( |
| 201 | - 'The password must appear at least once in data breaches.|' . |
|
| 201 | + 'The password must appear at least once in data breaches.|'. |
|
| 202 | 202 | 'The password must appear at least %count% times in data breaches.', |
| 203 | 203 | ['%count%' => $constraint->getMin()] |
| 204 | 204 | ); |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | |
| 213 | 213 | if ($constraint->getMin() === 0) { |
| 214 | 214 | return $translator->trans( |
| 215 | - 'The password must appear at most once in data breaches.|' . |
|
| 215 | + 'The password must appear at most once in data breaches.|'. |
|
| 216 | 216 | 'The password must appear at most %count% times in data breaches.', |
| 217 | 217 | ['%count%' => $constraint->getMax()] |
| 218 | 218 | ); |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | |
| 221 | 221 | if ($constraint->getMin() === $constraint->getMax()) { |
| 222 | 222 | return $translator->trans( |
| 223 | - 'The password must appear exactly once in data breaches.|' . |
|
| 223 | + 'The password must appear exactly once in data breaches.|'. |
|
| 224 | 224 | 'The password must appear exactly %count% times in data breaches.', |
| 225 | 225 | ['%count%' => $constraint->getMin()] |
| 226 | 226 | ); |