Completed
Push — master ( 95b8e4...b19727 )
by Dmitry
06:52
created

ServiceProvider   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 28 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 42.86%

Importance

Changes 4
Bugs 2 Features 0
Metric Value
wmc 1
lcom 0
cbo 4
dl 7
loc 25
ccs 6
cts 14
cp 0.4286
rs 10
c 4
b 2
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 7 17 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Basis\Provider;
4
5
use Basis\Application;
6
use Basis\Cache;
7
use Basis\Config;
8
use Basis\Event;
9
use Basis\Filesystem;
10
use Basis\Service;
11
use League\Container\ServiceProvider\AbstractServiceProvider;
12
use Tarantool\Mapper\Pool;
13
14
class ServiceProvider extends AbstractServiceProvider
15
{
16
    protected $provides = [
17
        Event::class,
18
        Service::class,
19
    ];
20
21
    public function register()
22
    {
23 7 View Code Duplication
        $this->getContainer()->share(Event::class, function () {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
24 7
            $app = $this->getContainer()->get(Application::class);
25 7
            $service = $this->getContainer()->get(Service::class);
26 7
            $pool = $this->getContainer()->get(Pool::class);
27 7
            $filesystem = $this->getContainer()->get(Filesystem::class);
28 7
            return new Event($app, $service, $pool, $filesystem);
29
        });
30
31
        $this->getContainer()->share(Service::class, function () {
32
            $config = $this->getContainer()->get(Config::class);
33
            $app = $this->getContainer()->get(Application::class);
34
            $cache = $this->getContainer()->get(Cache::class);
35
            return new Service($config['service'], $app, $cache);
36
        });
37
    }
38
}
39