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

CacheFactory::buildMemcached()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 1
dl 0
loc 10
ccs 6
cts 6
cp 1
crap 2
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