| Conditions | 4 | 
| Paths | 3 | 
| Total Lines | 29 | 
| Code Lines | 15 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Tests | 0 | 
| CRAP Score | 20 | 
| Changes | 1 | ||
| Bugs | 0 | Features | 0 | 
| 1 | <?php | ||
| 72 | public function setBlockOperationMode($mode) | ||
| 73 |     { | ||
| 74 | $validModes = [ | ||
| 75 | self::CBC_MODE, | ||
| 1 ignored issue–
                            show | |||
| 76 | self::CFB_MODE, | ||
| 1 ignored issue–
                            show | |||
| 77 | self::OFB_MODE, | ||
| 1 ignored issue–
                            show | |||
| 78 | self::CTR_MODE, | ||
| 1 ignored issue–
                            show | |||
| 79 | self::ECB_MODE | ||
| 1 ignored issue–
                            show | |||
| 80 | ]; | ||
| 81 | |||
| 82 |         if (!is_string($mode) || !in_array(strtoupper($mode), $validModes, true)) { | ||
| 1 ignored issue–
                            show | |||
| 83 | throw new \InvalidArgumentException( | ||
| 84 | 'The mode of operation must be a string and be a standardized block mode name.' | ||
| 85 | ); | ||
| 86 | } | ||
| 87 | |||
| 88 | $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 | $this->mode = strtoupper($mode); | ||
| 99 | |||
| 100 | return $this; | ||
| 101 | } | ||
| 156 |