Tiqr_UserStorage   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 3
eloc 7
c 2
b 0
f 1
dl 0
loc 27
ccs 6
cts 6
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getStorage() 0 10 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 Ivo Jansch <[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
/**
23
 * Class implementing a factory to retrieve user data.
24
 *
25
 * @author ivo
26
 */
27
class Tiqr_UserStorage
28
{
29
    /**
30
     * Get a storage of a certain type
31
     *
32
     * @param String $type The type of storage to create. Supported
33
     *                     types are 'file', 'pdo' or the full class name of a custom solution.
34
     * @param array $options The options to pass to the storage
35
     *                       instance. See the documentation
36
     *                       in the UserStorage/ subdirectory for
37
     *                       options per type.
38
     * @param LoggerInterface $logger
39
     *
40
     * @return Tiqr_UserStorage_Interface
41
     *
42
     * @throws Exception An exception if an unknown user storage is requested.
43
     */
44 6
    public static function getStorage(string $type, array $options, LoggerInterface $logger): Tiqr_UserStorage_Interface
45
    {
46
        switch ($type) {
47 6
            case "file":
48 1
                return new Tiqr_UserStorage_File($options, $logger);
49 5
            case "pdo":
50 3
                return new Tiqr_UserStorage_Pdo($options, $logger);
51
        }
52
53 2
        throw new RuntimeException(sprintf('Unable to create a UserStorage instance of type: %s', $type));
54
    }
55
}
56