| Conditions | 2 |
| Paths | 2 |
| Total Lines | 19 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 2 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 40 | 6 | protected function execute(InputInterface $input, OutputInterface $output) |
|
| 41 | { |
||
| 42 | 6 | $entropy = $input->getOption('entropy'); |
|
| 43 | 6 | $format = $input->getOption('format'); |
|
| 44 | |||
| 45 | $formatters = [ |
||
| 46 | 6 | 'base64' => 'base64_encode', |
|
| 47 | 6 | 'hex' => 'bin2hex', |
|
| 48 | 6 | ]; |
|
| 49 | |||
| 50 | 6 | if (!isset($formatters[$format])) { |
|
| 51 | 3 | throw new \InvalidArgumentException('Unrecognized format: ' . $format); |
|
| 52 | } |
||
| 53 | |||
| 54 | 3 | $data = random_bytes($entropy); |
|
| 55 | 3 | $result = $formatters[$format]($data); |
|
| 56 | |||
| 57 | 3 | $output->writeln($result); |
|
| 58 | 3 | } |
|
| 59 | } |
||
| 61 |