| Total Complexity | 4 |
| Total Lines | 47 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 8 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 14 | class FastRouteCacheCommand extends Command |
||
| 15 | { |
||
| 16 | const INT_RETURN_OK = 0; |
||
| 17 | |||
| 18 | const INT_RETURN_FAIL = 1; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @var string |
||
| 22 | */ |
||
| 23 | protected static $defaultName = 'daft-framework:router:update-cache'; |
||
| 24 | |||
| 25 | 2 | public function execute(InputInterface $input, OutputInterface $output) : int |
|
| 26 | { |
||
| 27 | 2 | $cacheFilename = static::tempnamCheck($output); |
|
| 28 | |||
| 29 | 2 | if ( ! is_string($cacheFilename)) { |
|
| 30 | 1 | return self::INT_RETURN_FAIL; |
|
| 31 | } |
||
| 32 | |||
| 33 | 1 | unlink($cacheFilename); |
|
| 34 | |||
| 35 | 1 | $cacheFilename .= '.cache'; |
|
| 36 | |||
| 37 | /** |
||
| 38 | * @var string[] |
||
| 39 | * |
||
| 40 | * @psalm-var array<int, class-string<\SignpostMarv\DaftRouter\DaftSource>> |
||
| 41 | */ |
||
| 42 | 1 | $sources = $input->getArgument('sources'); |
|
| 43 | |||
| 44 | 1 | Compiler::ObtainDispatcher(['cacheFile' => $cacheFilename], ...$sources); |
|
| 45 | |||
| 46 | 1 | $output->write(file_get_contents($cacheFilename) ?: 'false'); |
|
| 47 | |||
| 48 | 1 | unlink($cacheFilename); |
|
| 49 | |||
| 50 | 1 | return self::INT_RETURN_OK; |
|
| 51 | } |
||
| 52 | |||
| 53 | 2 | protected function configure() : void |
|
| 61 | ); |
||
| 62 | 2 | } |
|
| 64 |