RedisPlugin::createRedisFacade()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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