Completed
Pull Request — master (#400)
by Alejandro
06:15 queued 49s
created

CacheFactory::addMemcachedServer()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2.032

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 2
dl 0
loc 8
ccs 4
cts 5
cp 0.8
crap 2.032
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Shlinkio\Shlink\Common\Factory;
5
6
use Doctrine\Common\Cache;
7
use Interop\Container\ContainerInterface;
8
use Shlinkio\Shlink\Core\Options\AppOptions;
9
use Zend\ServiceManager\Factory\FactoryInterface;
10
11
use function Shlinkio\Shlink\Common\env;
12
13
class CacheFactory implements FactoryInterface
14
{
15 2
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null): Cache\Cache
16
    {
17 2
        $appOptions = $container->get(AppOptions::class);
18 2
        $adapter = env('APP_ENV', 'pro') === 'pro' ? new Cache\ApcuCache() : new Cache\ArrayCache();
19 2
        $adapter->setNamespace((string) $appOptions);
20
21 2
        return $adapter;
22
    }
23
}
24