1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace PhpUnitGen\Container; |
4
|
|
|
|
5
|
|
|
use League\Flysystem\Adapter\Local; |
6
|
|
|
use League\Flysystem\Filesystem; |
7
|
|
|
use League\Flysystem\FilesystemInterface; |
8
|
|
|
use PhpUnitGen\Configuration\ConfigurationInterface\ConsoleConfigInterface; |
9
|
|
|
use PhpUnitGen\Container\ContainerInterface\ConsoleContainerFactoryInterface; |
10
|
|
|
use PhpUnitGen\Container\ContainerInterface\ContainerFactoryInterface; |
11
|
|
|
use PhpUnitGen\Container\ContainerInterface\ContainerInterface; |
12
|
|
|
use PhpUnitGen\Exception\ExceptionCatcher; |
13
|
|
|
use PhpUnitGen\Exception\ExceptionInterface\ExceptionCatcherInterface; |
14
|
|
|
use PhpUnitGen\Executor\ConsoleExecutor; |
15
|
|
|
use PhpUnitGen\Executor\DirectoryExecutor; |
16
|
|
|
use PhpUnitGen\Executor\ExecutorInterface\ConsoleExecutorInterface; |
17
|
|
|
use PhpUnitGen\Executor\ExecutorInterface\DirectoryExecutorInterface; |
18
|
|
|
use PhpUnitGen\Executor\ExecutorInterface\FileExecutorInterface; |
19
|
|
|
use PhpUnitGen\Executor\FileExecutor; |
20
|
|
|
use PhpUnitGen\Validator\FileValidator; |
21
|
|
|
use PhpUnitGen\Validator\ValidatorInterface\FileValidatorInterface; |
22
|
|
|
use Symfony\Component\Console\Style\StyleInterface; |
23
|
|
|
use Symfony\Component\Stopwatch\Stopwatch; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Class ConsoleContainerFactory. |
27
|
|
|
* |
28
|
|
|
* @author Paul Thébaud <[email protected]>. |
29
|
|
|
* @copyright 2017-2018 Paul Thébaud <[email protected]>. |
30
|
|
|
* @license https://opensource.org/licenses/MIT The MIT license. |
31
|
|
|
* @link https://github.com/paul-thebaud/phpunit-generator |
32
|
|
|
* @since Class available since Release 2.0.0. |
33
|
|
|
*/ |
34
|
|
|
class ConsoleContainerFactory implements ConsoleContainerFactoryInterface |
35
|
|
|
{ |
36
|
|
|
/** |
37
|
|
|
* @var ContainerFactoryInterface $containerFactory The basic container factory. |
38
|
|
|
*/ |
39
|
|
|
private $containerFactory; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* ConsoleContainerFactory constructor. |
43
|
|
|
* |
44
|
|
|
* @param ContainerFactoryInterface $containerFactory The basic container factory. |
45
|
|
|
*/ |
46
|
|
|
public function __construct(ContainerFactoryInterface $containerFactory) |
47
|
|
|
{ |
48
|
|
|
$this->containerFactory = $containerFactory; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* {@inheritdoc} |
53
|
|
|
*/ |
54
|
|
|
public function invoke( |
55
|
|
|
ConsoleConfigInterface $config, |
56
|
|
|
StyleInterface $output, |
57
|
|
|
Stopwatch $stopwatch |
58
|
|
|
): ContainerInterface { |
59
|
|
|
$container = $this->containerFactory->invoke($config); |
60
|
|
|
|
61
|
|
|
$container->setInstance(FilesystemInterface::class, new Filesystem(new Local('./'))); |
62
|
|
|
$container->setInstance(StyleInterface::class, $output); |
63
|
|
|
$container->setInstance(Stopwatch::class, $stopwatch); |
64
|
|
|
|
65
|
|
|
$container->set(ExceptionCatcherInterface::class, ExceptionCatcher::class); |
66
|
|
|
$container->set(FileValidatorInterface::class, FileValidator::class); |
67
|
|
|
$container->set(FileExecutorInterface::class, FileExecutor::class); |
68
|
|
|
$container->set(DirectoryExecutorInterface::class, DirectoryExecutor::class); |
69
|
|
|
$container->set(ConsoleExecutorInterface::class, ConsoleExecutor::class); |
70
|
|
|
|
71
|
|
|
return $container; |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|