Passed
Branch 1.0 (690a53)
by Vladimir
07:08
created

Factory::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 23
ccs 0
cts 12
cp 0
rs 9.0856
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\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 $routesPrefix = ''
22
    ): Kernel {
23
        $container->delegate(new ReflectionContainer());
24
25
        $container->add('base_path', $basePath);
26
27
        // Load service providers
28
        $container->addServiceProvider(new RouteServiceProvider($routesPrefix));
29
        $container->addServiceProvider(new FilesystemServiceProvider(new Local($basePath)));
30
        $container->addServiceProvider(new DriverServiceProvider());
31
        $container->addServiceProvider(new ChannelServiceProvider());
32
        $container->addServiceProvider(new IntentServiceProvider());
33
        $container->addServiceProvider(new ContextServiceProvider());
34
35
        $kernel = new Kernel($container);
36
37
        $container->add(Kernel::class, $kernel);
38
39
        return $kernel;
40
    }
41
}
42