| Conditions | 4 |
| Paths | 3 |
| Total Lines | 29 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 4 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 72 | 60 | public function setBlockOperationMode($mode) |
|
| 73 | { |
||
| 74 | $validModes = [ |
||
| 75 | 60 | self::CBC_MODE, |
|
|
1 ignored issue
–
show
|
|||
| 76 | 60 | self::CFB_MODE, |
|
|
1 ignored issue
–
show
|
|||
| 77 | 60 | self::OFB_MODE, |
|
|
1 ignored issue
–
show
|
|||
| 78 | 60 | self::CTR_MODE, |
|
|
1 ignored issue
–
show
|
|||
| 79 | 60 | self::ECB_MODE |
|
|
1 ignored issue
–
show
|
|||
| 80 | ]; |
||
| 81 | |||
| 82 | 60 | if (!is_string($mode) || !in_array(strtoupper($mode), $validModes, true)) { |
|
|
1 ignored issue
–
show
|
|||
| 83 | 24 | throw new \InvalidArgumentException( |
|
| 84 | 24 | 'The mode of operation must be a string and be a standardized block mode name.' |
|
| 85 | ); |
||
| 86 | } |
||
| 87 | |||
| 88 | 36 | $newMethodName = static::ALGORITHM_NAME . '-' . (static::KEY_SIZE * 8) . '-' . $mode; |
|
|
2 ignored issues
–
show
|
|||
| 89 | |||
| 90 | // @codeCoverageIgnoreStart |
||
| 91 | if (!in_array($newMethodName, openssl_get_cipher_methods(), true)) { |
||
| 92 | throw new \RuntimeException( |
||
| 93 | 'The algorithm `' . $newMethodName . '`is not supported under the current system configuration.' |
||
| 94 | ); |
||
| 95 | } |
||
| 96 | // @codeCoverageIgnoreEnd |
||
| 97 | |||
| 98 | 36 | $this->mode = strtoupper($mode); |
|
| 99 | |||
| 100 | 36 | return $this; |
|
| 101 | } |
||
| 156 |