for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Stats;
use Joomla\Application\Cli\ColorStyle;
use Joomla\Application\Cli\Output\Processor\ColorProcessor;
use Joomla\Controller\AbstractController;
use Joomla\DI\ContainerAwareInterface;
use Joomla\DI\ContainerAwareTrait;
/**
* CLI Console
*
* @since 1.0
*/
class Console implements ContainerAwareInterface
{
use ContainerAwareTrait;
* Array of available command objects
* @var CommandInterface[]
private $commands = [];
* Get the available commands.
* @return CommandInterface[]
* @throws \RuntimeException
public function getCommands()
if (empty($this->commands))
$this->commands = $this->loadCommands();
}
return $this->commands;
* Load the application's commands
private function loadCommands()
$commands = [];
/** @var \DirectoryIterator $fileInfo */
foreach (new \DirectoryIterator(__DIR__ . '/Commands') as $fileInfo)
if ($fileInfo->isDot() || !$fileInfo->isFile())
continue;
$command = $fileInfo->getBasename('.php');
$className = __NAMESPACE__ . "\\Commands\\$command";
if (false == class_exists($className))
===
When comparing two booleans, it is generally considered safer to use the strict comparison operator.
throw new \RuntimeException(sprintf('Required class "%s" not found.', $className));
$commands[strtolower(str_replace('Command', '', $command))] = $this->getContainer()->get($className);
return $commands;
When comparing two booleans, it is generally considered safer to use the strict comparison operator.