Passed
Pull Request — develop (#27)
by Michiel
06:20
created

Tiqr_UserStorage_Encryption::getEncryption()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 17
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3.512

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 17
ccs 8
cts 13
cp 0.6153
rs 9.8333
cc 3
nc 3
nop 3
crap 3.512
1
<?php
2
/**
3
 * This file is part of the tiqr project.
4
 * 
5
 * The tiqr project aims to provide an open implementation for 
6
 * authentication using mobile devices. It was initiated by 
7
 * SURFnet and developed by Egeniq.
8
 *
9
 * More information: http://www.tiqr.org
10
 *
11
 * @author Peter Verhage <[email protected]>
12
 * 
13
 * @package tiqr
14
 *
15
 * @license New BSD License - See LICENSE file for details.
16
 *
17
 * @copyright (C) 2010-2012 SURFnet BV
18
 */
19
20
use Psr\Log\LoggerInterface;
21
22 1
require_once 'Tiqr/UserSecretStorage/Encryption/Interface.php';
23
24
/**
25
 * Class implementing a factory for user storage encryption.
26
 *
27
 * @author peter
28
 */
29
class Tiqr_UserStorage_Encryption
30
{
31
    /**
32
     * Get an encryption handler of a certain type (default: 'file')
33
     *
34
     * @param String $type The type of storage to create. Supported
35
     *                     types are 'dummy', 'mcrypt' or the full class name.
36
     * @param array $options The options to pass to the storage
37
     *                       instance. See the documentation
38
     *                       in the Encryption subdirectory for
39
     *                       options per type.
40
     *
41
     * @return Tiqr_UserStorage_Encryption_Interface
0 ignored issues
show
Bug introduced by
The type Tiqr_UserStorage_Encryption_Interface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
42
     */
43 10
    public static function getEncryption(LoggerInterface $logger, $type="dummy", $options=array())
44
    {
45 10
        $logger->info(sprintf('Using %s as UserStorage encryption type', $type));
46 10
        switch ($type) {
47 10
            case "dummy":
48 10
                require_once("Tiqr/UserSecretStorage/Encryption/Dummy.php");
49 10
                $instance = new Tiqr_UserSecretStorage_Encryption_Dummy($options);
50 10
                break;
51
            case "mcrypt":
52
                require_once("Tiqr/UserSecretStorage/Encryption/Mcrypt.php");
53
                $instance = new Tiqr_UserSecretStorage_Encryption_Mcrypt($options);
54
                break;
55
            default: 
56
                $instance = new $type($options);
57
        }
58
        
59 10
        return $instance;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $instance also could return the type Tiqr_UserSecretStorage_E...orage_Encryption_Mcrypt which is incompatible with the documented return type Tiqr_UserStorage_Encryption_Interface.
Loading history...
60
    }
61
}
62