Completed
Push — 1.0 ( 690a53...47c60b )
by Vladimir
05:44
created

Factory::create()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 26
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 26
ccs 0
cts 14
cp 0
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 19
nc 1
nop 4
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FondBot\Application;
6
7
use League\Container\Container;
8
use League\Flysystem\Adapter\Local;
9
use League\Container\ReflectionContainer;
10
use FondBot\Drivers\DriverServiceProvider;
11
use FondBot\Channels\ChannelServiceProvider;
12
use FondBot\Conversation\IntentServiceProvider;
13
use FondBot\Conversation\ContextServiceProvider;
14
use FondBot\Filesystem\FilesystemServiceProvider;
15
16
class Factory
17
{
18
    public static function create(
19
        Container $container,
20
        string $basePath,
21
        string $resourcesPath,
22
        string $routesPrefix = ''
23
    ): Kernel {
24
        $container->delegate(new ReflectionContainer());
25
26
        $container->add('base_path', $basePath);
27
        $container->add('resources_path', $resourcesPath);
28
29
        // Load service providers
30
        $container->addServiceProvider(new LogServiceProvider());
31
        $container->addServiceProvider(new RouteServiceProvider($routesPrefix));
32
        $container->addServiceProvider(new FilesystemServiceProvider(new Local($basePath)));
33
        $container->addServiceProvider(new DriverServiceProvider());
34
        $container->addServiceProvider(new ChannelServiceProvider());
35
        $container->addServiceProvider(new IntentServiceProvider());
36
        $container->addServiceProvider(new ContextServiceProvider());
37
38
        $kernel = new Kernel($container);
39
40
        $container->add(Kernel::class, $kernel);
41
42
        return $kernel;
43
    }
44
}
45