forked from Tiqr/tiqr-server-libphp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserStorage.php
More file actions
55 lines (52 loc) · 1.63 KB
/
Copy pathUserStorage.php
File metadata and controls
55 lines (52 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
/**
* This file is part of the tiqr project.
*
* The tiqr project aims to provide an open implementation for
* authentication using mobile devices. It was initiated by
* SURFnet and developed by Egeniq.
*
* More information: http://www.tiqr.org
*
* @author Ivo Jansch <ivo@egeniq.com>
*
* @package tiqr
*
* @license New BSD License - See LICENSE file for details.
*
* @copyright (C) 2010-2012 SURFnet BV
*/
use Psr\Log\LoggerInterface;
/**
* Class implementing a factory to retrieve user data.
*
* @author ivo
*/
class Tiqr_UserStorage
{
/**
* Get a storage of a certain type
*
* @param String $type The type of storage to create. Supported
* types are 'file', 'pdo' or the full class name of a custom solution.
* @param array $options The options to pass to the storage
* instance. See the documentation
* in the UserStorage/ subdirectory for
* options per type.
* @param LoggerInterface $logger
*
* @return Tiqr_UserStorage_Interface
*
* @throws Exception An exception if an unknown user storage is requested.
*/
public static function getStorage(string $type, array $options, LoggerInterface $logger): Tiqr_UserStorage_Interface
{
switch ($type) {
case "file":
return new Tiqr_UserStorage_File($options, $logger);
case "pdo":
return new Tiqr_UserStorage_Pdo($options, $logger);
}
throw new RuntimeException(sprintf('Unable to create a UserStorage instance of type: %s', $type));
}
}