Code Duplication    Length = 24-26 lines in 2 locations

src/Client/Adapter/AdapterFactory.php 1 location

@@ 10-35 (lines=26) @@
7
use Buttress\Concrete\Locator\Site;
8
use Psr\Container\ContainerInterface;
9
10
class AdapterFactory
11
{
12
13
    /** @var \Psr\Container\ContainerInterface */
14
    private $container;
15
16
    public function __construct(ContainerInterface $container)
17
    {
18
        $this->container = $container;
19
    }
20
21
    /**
22
     * Get an adapter from a site object
23
     *
24
     * @param \Buttress\Concrete\Locator\Site $site
25
     * @return mixed
26
     */
27
    public function fromSite(Site $site)
28
    {
29
        $version = version_compare($site->getVersion(), '5.6.999999');
30
        $legacy = $version === -1;
31
32
        return $this->container->get($legacy ? LegacyAdapter::class : ModernAdapter::class);
33
    }
34
35
}
36

src/Service/Package/DriverFactory.php 1 location

@@ 10-33 (lines=24) @@
7
use Buttress\Concrete\Locator\Site;
8
use Psr\Container\ContainerInterface;
9
10
class DriverFactory
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;
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