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

Tiqr_UserStorage_File::_loadUser()   A

Complexity

Conditions 4
Paths 6

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 4.016

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 17
ccs 9
cts 10
cp 0.9
rs 9.9
cc 4
nc 6
nop 2
crap 4.016
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
use Psr\Log\LoggerInterface;
21
22
require_once 'Tiqr/UserStorage/FileTrait.php';
23
require_once 'Tiqr/UserStorage/GenericStore.php';
24
25
/**
26
 * This user storage implementation implements a simple user storage using json files.
27
 * This is mostly for demonstration and development purposes. In a production environment
28
 * please supply your own implementation that hosts the data in your user database OR
29
 * in a secure (e.g. hardware encrypted) storage.
30
 * @author ivo
31
 */
32
class Tiqr_UserStorage_File extends Tiqr_UserStorage_GenericStore
33
{
34
    use FileTrait;
35
36
    protected $path;
37 1
38
    /**
39 1
     * Create an instance
40 1
     * @param $config
41 1
     */
42
    public function __construct($config, LoggerInterface $logger)
43
    {
44
        parent::__construct($config, $logger);
45
        $this->path = $config["path"];
46
    }
47
48 1
    /**
49
     * Delete user data (un-enroll).
50 1
     * @param String $userId
51 1
     */
52
    protected function _deleteUser($userId)
53
    {
54
        $filename = $this->getPath().$userId.".json";
55
        if (file_exists($filename)) {
56
            unlink($filename);
57
        } else {
58
            $this->logger->error('Unable to remove the user from user storage (file storage)');
59 1
        }
60
    }
61
}
62