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