DoctrineServiceProvider   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 4
dl 28
loc 28
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 4 4 1
A registerContainerBindings() 12 12 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 namespace Nord\Lumen\FileManager\Doctrine\ORM;
2
3
use Doctrine\ORM\EntityManagerInterface;
4
use Illuminate\Contracts\Container\Container;
5
use Illuminate\Support\ServiceProvider;
6
use Nord\Lumen\FileManager\Contracts\FileFactory as FileFactoryContract;
7
use Nord\Lumen\FileManager\Contracts\FileStorage as FileStorageContract;
8
use Nord\Lumen\FileManager\Doctrine\FileFactory;
9
10 View Code Duplication
class DoctrineServiceProvider extends ServiceProvider
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in 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...
11
{
12
13
    /**
14
     * @inheritdoc
15
     */
16
    public function register()
17
    {
18
        $this->registerContainerBindings($this->app);
19
    }
20
21
22
    /**
23
     * @param Container $container
24
     */
25
    protected function registerContainerBindings(Container $container)
26
    {
27
        $container->singleton(FileFactoryContract::class, function () {
28
            return new FileFactory(File::class);
29
        });
30
31
        $entityManager = $container->make(EntityManagerInterface::class);
32
33
        $container->singleton(FileStorageContract::class, function () use ($entityManager) {
34
            return new FileStorage($entityManager);
35
        });
36
    }
37
}
38