Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 10
Maintenance
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 2
12
0.00% covered (danger)
0.00%
0 / 10
 configure
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 execute
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 8
<?php
    
namespace Eywa\Console\Mode
{
    use Eywa\Exception\Kedavra;
    use Eywa\File\File;
    use Symfony\Component\Console\Command\Command;
    use Symfony\Component\Console\Input\InputInterface;
    use Symfony\Component\Console\Output\OutputInterface;
    use Symfony\Component\Console\Style\SymfonyStyle;
    class Maintenance extends Command
    {
        protected static $defaultName = 'app:down';
            
        protected function configure(): void
        {
            $this->setDescription('Put the application in maintenance mode');
        }
        /**
         * @param InputInterface $input
         * @param OutputInterface $output
         * @return int|void
         * @throws Kedavra
         */
        public function execute(InputInterface $input, OutputInterface $output)
        {
            $io = new SymfonyStyle($input, $output);
            $io->title('Enabling the maintenance mode');
            if (
                (new File('config/mode.yaml', EMPTY_AND_WRITE_FILE_MODE))
                    ->write("mode: down\nconnexion: prod")->flush()
            ) {
                $io->success('The application is now in maintenance mode');
                return 0;
            }
            $io->error('Checkout mode has failed');
            return 1;
        }
    }
}