Passed
Push — develop ( 879873...e4bddd )
by Nikolay
03:54
created

CryptProvider   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 12 1
1
<?php
2
/*
3
 * MikoPBX - free phone system for small business
4
 * Copyright (C) 2017-2020 Alexey Portnov and Nikolay Beketov
5
 *
6
 * This program is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation; either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License along with this program.
17
 * If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
declare(strict_types=1);
21
22
23
namespace MikoPBX\AdminCabinet\Providers;
24
25
26
use Phalcon\Crypt;
27
use Phalcon\Di\DiInterface;
28
use Phalcon\Di\ServiceProviderInterface;
29
30
/**
31
 * Register a crypt provider
32
 */
33
class CryptProvider implements ServiceProviderInterface
34
{
35
    public const SERVICE_NAME = 'crypt';
36
37
    /**
38
     * Register elements service provider
39
     *
40
     * @param \Phalcon\Di\DiInterface $di
41
     */
42
    public function register(DiInterface $di): void
43
    {
44
        $encryptionKey = $di->getShared('config')->path('www.encryptionKey');
45
        $di->setShared(
46
            self::SERVICE_NAME,
47
            function () use ($di, $encryptionKey) {
0 ignored issues
show
Unused Code introduced by
The import $di is not used and could be removed.

This check looks for imports that have been defined, but are not used in the scope.

Loading history...
48
                $crypt = new Crypt();
49
                // Set a global encryption key
50
                $crypt->setKey(
51
                    $encryptionKey
52
                );
53
                return $crypt;
54
            }
55
        );
56
    }
57
}