RedisPlugin   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 9
c 2
b 0
f 0
dl 0
loc 28
ccs 13
cts 13
cp 1
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A createRedisManager() 0 3 1
A createRedisFactory() 0 3 1
A createRedisFacade() 0 3 1
A provideDependencies() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 *  This file is part of the Micro framework package.
7
 *
8
 *  (c) Stanislau Komar <[email protected]>
9
 *
10
 *  For the full copyright and license information, please view the LICENSE
11
 *  file that was distributed with this source code.
12
 */
13
14
namespace Micro\Plugin\Redis;
15
16
use Micro\Component\DependencyInjection\Container;
17
use Micro\Framework\Kernel\Plugin\ConfigurableInterface;
18
use Micro\Framework\Kernel\Plugin\DependencyProviderInterface;
19
use Micro\Framework\Kernel\Plugin\PluginConfigurationTrait;
20
use Micro\Plugin\Redis\Business\Redis\RedisFactory;
21
use Micro\Plugin\Redis\Business\Redis\RedisFactoryInterface;
22
use Micro\Plugin\Redis\Business\Redis\RedisManager;
23
use Micro\Plugin\Redis\Business\Redis\RedisManagerInterface;
24
use Micro\Plugin\Redis\Facade\RedisFacade;
25
26
/**
27
 * @method RedisPluginConfigurationInterface configuration()
28
 */
29
class RedisPlugin implements DependencyProviderInterface, ConfigurableInterface
30
{
31
    use PluginConfigurationTrait;
32
33 1
    public function provideDependencies(Container $container): void
34
    {
35 1
        $container->register(\Micro\Plugin\Redis\Facade\RedisFacadeInterface::class, function (): Facade\RedisFacadeInterface {
36 1
            return $this->createRedisFacade();
37 1
        });
38
39 1
        $container->register(RedisFacadeInterface::class, function (Container $container) { // Deprecation support
40 1
            return $container->get(\Micro\Plugin\Redis\Facade\RedisFacadeInterface::class);
41 1
        });
42
    }
43
44 1
    protected function createRedisFacade(): Facade\RedisFacadeInterface
45
    {
46 1
        return new RedisFacade($this->createRedisManager());
47
    }
48
49 1
    protected function createRedisManager(): RedisManagerInterface
50
    {
51 1
        return new RedisManager($this->createRedisFactory(), $this->configuration());
52
    }
53
54 1
    protected function createRedisFactory(): RedisFactoryInterface
55
    {
56 1
        return new RedisFactory();
57
    }
58
}
59