Passed
Pull Request — master (#99)
by Wilmer
12:59
created

CacheProvider   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 4
c 1
b 0
f 0
dl 0
loc 10
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Provider;
6
7
use Psr\Container\ContainerInterface;
8
use Psr\SimpleCache\CacheInterface;
9
use Yiisoft\Aliases\Aliases;
10
use Yiisoft\Cache\Cache;
11
use Yiisoft\Cache\CacheInterface as YiiCacheInterface;
12
use Yiisoft\Cache\File\FileCache;
13
use Yiisoft\Di\Container;
14
use Yiisoft\Di\Support\ServiceProvider;
15
16
final class CacheProvider extends ServiceProvider
17
{
18
    public function register(Container $container): void
19
    {
20
        //cache
21
        $container->set(CacheInterface::class, static function (ContainerInterface $container) {
22
            return new FileCache($container->get(Aliases::class)->get('@runtime/cache'));
23
        });
24
25
        $container->set(YiiCacheInterface::class, Cache::class);
26
    }
27
}
28