Completed
Push — master ( c4e3cd...c5cae6 )
by Anton
05:38
created

EncrypterManager   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 28
wmc 2
lcom 1
cbo 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A createInjection() 0 4 1
1
<?php
2
/**
3
 * Spiral Framework.
4
 *
5
 * @license   MIT
6
 * @author    Anton Titov (Wolfy-J)
7
 */
8
namespace Spiral\Encrypter;
9
10
use Spiral\Core\Container\InjectorInterface;
11
use Spiral\Core\Container\SingletonInterface;
12
use Spiral\Encrypter\Configs\EncrypterConfig;
13
14
/**
15
 * Only manages encrypter injections (factory).
16
 */
17
class EncrypterManager implements InjectorInterface, SingletonInterface
18
{
19
    /**
20
     * To be constructed only once.
21
     */
22
    const SINGLETON = self::class;
23
24
    /**
25
     * @var EncrypterConfig
26
     */
27
    protected $config = null;
28
29
    /**
30
     * @param EncrypterConfig $config
31
     */
32
    public function __construct(EncrypterConfig $config)
33
    {
34
        $this->config = $config;
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function createInjection(\ReflectionClass $class, $context = null)
41
    {
42
        return $class->newInstance($this->config->getKey(), $this->config->getCipher());
43
    }
44
}