for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* @author SignpostMarv
*/
declare(strict_types=1);
namespace SignpostMarv\DaftFramework\Symfony\Console\Command;
use SignpostMarv\DaftRouter\Router\Compiler;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class FastRouteCacheCommand extends Command
{
const INT_RETURN_OK = 0;
const INT_RETURN_FAIL = 1;
* @var string
protected static $defaultName = 'daft-framework:router:update-cache';
public function execute(InputInterface $input, OutputInterface $output) : int
$cacheFilename = static::tempnamCheck($output);
if ( ! is_string($cacheFilename)) {
return self::INT_RETURN_FAIL;
}
unlink($cacheFilename);
$cacheFilename .= '.cache';
* @var string[]
*
* @psalm-var array<int, class-string<\SignpostMarv\DaftRouter\DaftSource>>
$sources = $input->getArgument('sources');
Compiler::ObtainDispatcher(['cacheFile' => $cacheFilename], ...$sources);
$output->write(file_get_contents($cacheFilename) ?: 'false');
return self::INT_RETURN_OK;
protected function configure() : void
$this->setDescription(
'Update the cache used by the daft framework router'
)->addArgument(
'sources',
InputArgument::REQUIRED | InputArgument::IS_ARRAY,
'class names for sources'
);