for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
/*
* This file is part of the box project.
*
* (c) Kevin Herrera <[email protected]>
* Théo Fidry <[email protected]>
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace KevinGH\Box\Console\Command;
use KevinGH\Box\Configuration;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
/**
* Allows a configuration file path to be specified for a command.
abstract class Configurable extends Command
{
private const CONFIG_PARAM = 'config';
* {@inheritdoc}
protected function configure(): void
$this->addOption(
self::CONFIG_PARAM,
'c',
InputOption::VALUE_REQUIRED,
'The alternative configuration file path.'
);
}
* Returns the configuration settings.
* @param InputInterface $input the input handler
* @return Configuration the configuration settings
final protected function getConfig(InputInterface $input): Configuration
/** @var $helper \KevinGH\Box\Console\ConfigurationHelper */
$helper = $this->getHelper('config');
return $helper->loadFile($input->getOption(self::CONFIG_PARAM));