Completed
Push — master ( 83bd2d...9517e2 )
by Arne
03:10
created

ConnectionAdapterFactoryContainer::get()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 16
Code Lines 7

Duplication

Lines 16
Ratio 100 %

Importance

Changes 0
Metric Value
dl 16
loc 16
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 7
nc 3
nop 2
1
<?php
2
3
namespace Archivr\ConnectionAdapter;
4
5
use Archivr\AbstractServiceFactoryContainer;
6
use Archivr\ConnectionConfiguration;
7
8 View Code Duplication
class ConnectionAdapterFactoryContainer extends AbstractServiceFactoryContainer
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...
9
{
10
    function get(string $name, ConnectionConfiguration $connectionConfiguration)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
11
    {
12
        if (!isset($this->map[$name]))
13
        {
14
            return null;
15
        }
16
17
        $connection = ($this->map[$name])($connectionConfiguration);
18
19
        if (!($connection instanceof ConnectionAdapterInterface))
20
        {
21
            throw new \LogicException(sprintf('Factory closure for connection adapter "%s" does not return an instance of %s!', $name, ConnectionAdapterInterface::class));
22
        }
23
24
        return $connection;
25
    }
26
}
27