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

Tiqr_OcraService   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A getOcraService() 0 11 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 1
require_once("Tiqr/OcraService/Abstract.php");
21
22
use Psr\Log\LoggerInterface;
23
24
/**
25
 * Class implementing a factory to retrieve the ocra service to use
26
 *
27
 * @author lineke
28
 */
29
class Tiqr_OcraService
30
{
31
    /**
32
     * Get a ocra service of a certain type (default: 'tiqr')
33
     *
34
     * @param String $type The type of ocra service to create. Supported
35
     *                     types are 'tiqr' or 'oathservice'.
36
     * @param array $options The options to pass to the ocra service
37
     *                       instance.
38
     *
39
     * @return Tiqr_OcraService_Interface
40
     * @throws Exception An exception if an unknown orca service type is requested.
41
     */
42 7
    public static function getOcraService($type="tiqr", $options=array(), LoggerInterface $logger)
43
    {
44 7
        switch ($type) {
45 7
            case "tiqr":
46 5
                require_once("Tiqr/OcraService/Tiqr.php");
47 5
                return new Tiqr_OcraService_Tiqr($options, $logger);
48 2
            case "oathserviceclient":
49 1
                require_once("Tiqr/OcraService/OathServiceClient.php");
50 1
                return new Tiqr_OcraService_OathServiceClient($options, $logger);
51
        }
52 1
        throw new RuntimeException(sprintf('Unable to create a OcraService instance of type: %s', $type));
53
    }
54
}
55