Completed
Push — master ( 8cea3f...bca2c3 )
by Dmitry
03:51
created

Application   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
c 1
b 0
f 0
lcom 1
cbo 3
dl 0
loc 43
ccs 24
cts 24
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 20 2
A dispatch() 0 4 1
A get() 0 14 4
1
<?php
2
3
namespace Basis;
4
5
use League\Container\Container;
6
use League\Container\ReflectionContainer;
7
use Tarantool\Mapper\Mapper;
8
use Tarantool\Mapper\Plugin\Annotation;
9
use Tarantool\Mapper\Repository;
10
11
class Application extends Container
12
{
13 12
    public function __construct($root)
14
    {
15 12
        parent::__construct();
16
17 12
        $fs = new Filesystem($this, $root);
18
19 12
        $this->share(Application::class, $this);
20 12
        $this->share(Container::class, $this);
21 12
        $this->share(Filesystem::class, $fs);
22
23 12
        $this->addServiceProvider(Provider\CoreProvider::class);
24 12
        $this->addServiceProvider(Provider\ServiceProvider::class);
25 12
        $this->addServiceProvider(Provider\TarantoolProvider::class);
26
27 12
        foreach ($fs->listClasses('Provider') as $provider) {
28 12
            $this->addServiceProvider($provider);
29
        }
30
31 12
        $this->delegate(new ReflectionContainer());
32 12
    }
33
34 6
    public function dispatch($job, $params = [])
35
    {
36 6
        return $this->get(Runner::class)->dispatch($job, $params);
37
    }
38
39 12
    public function get($alias, array $args = [])
40
    {
41 12
        if (!$this->hasShared($alias, true) && is_subclass_of($alias, Repository::class)) {
0 ignored issues
show
Bug introduced by
Due to PHP Bug #53727, is_subclass_of might return inconsistent results on some PHP versions if \Tarantool\Mapper\Repository::class can be an interface. If so, you could instead use ReflectionClass::implementsInterface.
Loading history...
42 1
            $spaceName = $this->get(Mapper::class)
43 1
                ->getPlugin(Annotation::class)
44 1
                ->getRepositorySpaceName($alias);
45
46 1
            if ($spaceName) {
47 1
                $instance = $this->get(Mapper::class)->getRepository($spaceName);
48 1
                $this->share($alias, $instance);
49
            }
50
        }
51 12
        return parent::get($alias, $args);
52
    }
53
}
54