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

Factory   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 10

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 10
dl 0
loc 26
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 23 1
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