Conditions | 4 |
Paths | 4 |
Total Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Tests | 5 |
CRAP Score | 6 |
Changes | 0 |
1 | <?php |
||
30 | 1 | public function generateIv(bool $allowLessSecureIv = false): string |
|
31 | { |
||
32 | 1 | $success = false; |
|
33 | 1 | $random = openssl_random_pseudo_bytes(openssl_cipher_iv_length(static::CIPHER), $success); |
|
34 | 1 | if (!$success) { |
|
35 | try { |
||
36 | $random = random_bytes(static::IV_LENGTH); |
||
37 | } catch (Exception $e) { |
||
38 | if ($allowLessSecureIv) { |
||
39 | $random = $this->generateInsecureIv(static::IV_LENGTH); |
||
40 | } else { |
||
41 | throw new RuntimeException('Unable to generate initialization vector (IV)'); |
||
42 | } |
||
43 | } |
||
44 | } |
||
45 | 1 | return $random; |
|
46 | } |
||
47 | } |
||
48 |
This check examines a number of code elements and verifies that they conform to the given naming conventions.
You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.