Tiqr_OcraService_Abstract   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A generateChallenge() 0 3 1
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
abstract class Tiqr_OcraService_Abstract implements Tiqr_OcraService_Interface
23
{
24
    /** @var OATH_OCRAParser */
25
    protected $_ocraParser;
26
    /** @var String */
27
    protected $_ocraSuite;
28
    /** @var LoggerInterface  */
29
    protected $logger;
30
31
    /**
32
     * @throws Exception
33
     */
34 12
    public function __construct(array $config, LoggerInterface $logger) {
35 12
        $this->logger = $logger;
36
37
        // Set the OCRA suite
38 12
        $this->_ocraSuite = $config['ocra.suite'] ?? 'OCRA-1:HOTP-SHA1-6:QH10-S';   // Use tiqr server default suite
39 12
        $this->_ocraParser = new OATH_OCRAParser($this->_ocraSuite);
40
    }
41
42
    /**
43
     * Generate a challenge string based on an ocraSuite
44
     * @return String An OCRA challenge that matches the specification of
45
     *         the ocraSuite.
46
     * @throws Exception
47
     */
48 6
    public function generateChallenge(): string
49
    {
50 6
        return $this->_ocraParser->generateChallenge();
51
    }
52
53
}