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

EncrypterManager::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 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
}