registerContainerBindings()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 6

Duplication

Lines 12
Ratio 100 %

Importance

Changes 0
Metric Value
dl 12
loc 12
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 1
1
<?php namespace Nord\Lumen\FileManager\Doctrine\ODM;
2
3
use Doctrine\ODM\MongoDB\DocumentManager;
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
        $documentManager = $container->make(DocumentManager::class);
32
33
        $container->singleton(FileStorageContract::class, function () use ($documentManager) {
34
            return new FileStorage($documentManager);
35
        });
36
    }
37
}
38