Passed
Push — develop ( 22eefe...e65dcd )
by Pieter van der
06:04
created

Tiqr_UserStorage_Encryption   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 58.33%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 13
c 1
b 0
f 0
dl 0
loc 30
ccs 7
cts 12
cp 0.5833
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getEncryption() 0 16 3
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 1
require_once 'Tiqr/UserStorage/Encryption/Interface.php'; 
21
22
/**
23
 * Class implementing a factory for user storage encryption.
24
 *
25
 * @author peter
26
 */
27
class Tiqr_UserStorage_Encryption
28
{
29
    /**
30
     * Get an encryption handler of a certain type (default: 'file')
31
     *
32
     * @param String $type The type of storage to create. Supported
33
     *                     types are 'dummy', 'mcrypt' or the full class name.
34
     * @param array $options The options to pass to the storage
35
     *                       instance. See the documentation
36
     *                       in the Encryption subdirectory for
37
     *                       options per type.
38
     *
39
     * @return Tiqr_UserStorage_Encryption_Interface
40
     */
41 1
    public static function getEncryption($type="dummy", $options=array())
42
    {
43 1
        switch ($type) {
44 1
            case "dummy":
45 1
                require_once("Tiqr/UserStorage/Encryption/Dummy.php");
46 1
                $instance = new Tiqr_UserStorage_Encryption_Dummy($options);
47 1
                break;
48
            case "mcrypt":
49
                require_once("Tiqr/UserStorage/Encryption/Mcrypt.php");
50
                $instance = new Tiqr_UserStorage_Encryption_Mcrypt($options);
51
                break;
52
            default: 
53
                $instance = new $type($options);
54
        }
55
        
56 1
        return $instance;
57
    }
58
}
59