for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace PhpUnitGen\Exception;
use PhpUnitGen\Configuration\ConfigurationInterface\ConsoleConfigInterface;
use PhpUnitGen\Exception\ExceptionInterface\ExceptionCatcherInterface;
use Symfony\Component\Console\Style\StyleInterface;
/**
* Class ExceptionCatcher.
*
* @author Paul Thébaud <[email protected]>.
* @copyright 2017-2018 Paul Thébaud <[email protected]>.
* @license https://opensource.org/licenses/MIT The MIT license.
* @link https://github.com/paul-thebaud/phpunit-generator
* @since Class available since Release 2.0.0.
*/
class ExceptionCatcher implements ExceptionCatcherInterface
{
* @var ConsoleConfigInterface $config The configuration to use.
private $config;
* @var StyleInterface $output The output to display message.
private $output;
* ExceptionCatcher constructor.
* @param ConsoleConfigInterface $config The config to use.
* @param StyleInterface $output The output to use.
public function __construct(
ConsoleConfigInterface $config,
StyleInterface $output
) {
$this->config = $config;
$this->output = $output;
}
* {@inheritdoc}
public function catch(Exception $exception): void
if ($this->config->hasIgnore()) {
$this->output->note($exception->getMessage());
} else {
throw new Exception($exception->getMessage());