Completed
Push — master ( 4ad075...9b6fee )
by Vladimir
07:02
created

Factory::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 21
ccs 0
cts 12
cp 0
rs 9.3142
c 0
b 0
f 0
cc 1
eloc 16
nc 1
nop 3
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FondBot\Toolbelt;
6
7
use League\Container\Container;
8
use League\Flysystem\Adapter\Local;
9
use FondBot\Toolbelt\Commands\MakeIntent;
10
use League\Container\ReflectionContainer;
11
use Symfony\Component\Console\Application;
12
use FondBot\Toolbelt\Commands\MakeInteraction;
13
use FondBot\Filesystem\FilesystemServiceProvider;
14
15
class Factory
16
{
17
    public static function create(
18
        Container $container,
19
        string $basePath,
20
        string $resourcesPath
21
    ): Kernel {
22
        $container->delegate(new ReflectionContainer());
23
24
        $container->add('base_path', $basePath);
25
        $container->add('resources_path', $resourcesPath);
26
        $container->addServiceProvider(new FilesystemServiceProvider(new Local($basePath)));
27
28
        $kernel = new Kernel($container);
29
        $console = new Application('FondBot', \FondBot\Application\Kernel::VERSION);
30
        $console->add(new MakeIntent($kernel));
31
        $console->add(new MakeInteraction($kernel));
32
33
        $container->add(Kernel::class, $kernel);
34
        $container->add('console', $console);
35
36
        return $kernel;
37
    }
38
}
39