Test Failed
Pull Request — develop (#30)
by Michiel
07:02
created

Tiqr_UserStorage   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 76.92%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 3
eloc 9
c 2
b 0
f 1
dl 0
loc 32
rs 10
ccs 10
cts 13
cp 0.7692

1 Method

Rating   Name   Duplication   Size   Complexity  
A getStorage() 0 12 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 (default: 'file')
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 array $secretoptions  The options to pass to the secret storage
39
     *                              instance. See the documentation
40
     *                              in the UserSecretStorage/ subdirectory for
41
     *                              options per type.
42
     *
43
     * @return Tiqr_UserStorage_Interface
44
     *
45 3
     * @throws Exception
46
     */
47 3
    public static function getStorage($type="file", $options=array(), $secretoptions=array(), LoggerInterface $logger)
48 3
    {
49 1
        switch ($type) {
50 1
            case "file":
51 1
                require_once("Tiqr/UserStorage/File.php");
52 2
                return new Tiqr_UserStorage_File($options, $logger, $secretoptions);
0 ignored issues
show
Unused Code introduced by
The call to Tiqr_UserStorage_File::__construct() has too many arguments starting with $secretoptions. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

52
                return /** @scrutinizer ignore-call */ new Tiqr_UserStorage_File($options, $logger, $secretoptions);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
53
            case "pdo":
54
                require_once("Tiqr/UserStorage/Pdo.php");
55
                return new Tiqr_UserStorage_Pdo($options, $logger, $secretoptions);
0 ignored issues
show
Unused Code introduced by
The call to Tiqr_UserStorage_Pdo::__construct() has too many arguments starting with $secretoptions. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

55
                return /** @scrutinizer ignore-call */ new Tiqr_UserStorage_Pdo($options, $logger, $secretoptions);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
56 2
        }
57 2
58 2
        throw new RuntimeException(sprintf('Unable to create a UserStorage instance of type: %s', $type));
59 2
    }
60
}
61