Conditions | 3 |
Paths | 3 |
Total Lines | 21 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 3.0052 |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
22 | 2 | public function __invoke( |
|
23 | ContainerInterface $container, |
||
24 | string $contextName = ConfigProvider::DEFAULT_CONTEXT |
||
25 | ): Context { |
||
26 | 2 | $contextConfig = ConfigProvider::getContextConfig($contextName, $container->get(ConfigProvider::CONFIG_KEY)); |
|
27 | |||
28 | 2 | $contextType = $contextConfig[ConfigProvider::CONTEXTS_TYPE_KEY]; |
|
29 | 2 | if (self::NULL === $contextType) { |
|
30 | 1 | return new NullContext(); |
|
31 | } |
||
32 | |||
33 | 1 | if (self::FILESYSTEM === $contextType) { |
|
34 | 1 | Assertion::classExists( |
|
35 | 1 | FsConnectionFactory::class, |
|
36 | 1 | 'Install "enqueue/fs" package to run filesystem context.' |
|
37 | ); |
||
38 | 1 | Assertion::keyExists($contextConfig, 'path', 'Absolute "path" is required to run filesystem context.'); |
|
39 | 1 | return (new FsConnectionFactory($contextConfig['path']))->createContext(); |
|
40 | } |
||
41 | |||
42 | throw new InvalidArgumentException(sprintf('There is not implementation for given context %s.', $contextType)); |
||
43 | } |
||
45 |