DriverFactory::getDriver()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 7
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 7
loc 7
ccs 0
cts 6
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 1
nop 1
crap 6
1
<?php
2
3
namespace Buttress\Concrete\Service\Package;
4
5
use Buttress\Concrete\Service\Package\Driver\LegacyDriver;
6
use Buttress\Concrete\Service\Package\Driver\ModernDriver;
7
use Buttress\Concrete\Locator\Site;
8
use Psr\Container\ContainerInterface;
9
10 View Code Duplication
class DriverFactory
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
    /** @var \Buttress\Concrete\Locator\Site */
14
    private $site;
15
16
    /** @var \Buttress\Concrete\Service\Package\Container */
17
    private $container;
18
19
    public function __construct(Site $site, ContainerInterface $container)
20
    {
21
        $this->site = $site;
22
        $this->container = $container;
0 ignored issues
show
Documentation Bug introduced by
It seems like $container of type object<Psr\Container\ContainerInterface> is incompatible with the declared type object<Buttress\Concrete...vice\Package\Container> of property $container.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
23
    }
24
25
    public function getDriver(Site $site)
26
    {
27
        $version = version_compare($site->getVersion(), '5.6.999999');
28
        $legacy = $version === -1;
29
30
        return $this->container->get($legacy ? LegacyDriver::class : ModernDriver::class);
31
    }
32
33
}
34