Tiqr_OcraService   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

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