Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
Bin2HexUriProvider | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
provide | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | /** |
4 | * This program is free software; you can redistribute it and/or |
5 | * modify it under the terms of the GNU General Public License |
6 | * as published by the Free Software Foundation; under version 2 |
7 | * of the License (non-upgradable). |
8 | * |
9 | * This program is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. |
13 | * |
14 | * You should have received a copy of the GNU General Public License |
15 | * along with this program; if not, write to the Free Software |
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
17 | * |
18 | * Copyright (c) 2002-2008 (original work) Public Research Centre Henri Tudor & University of Luxembourg |
19 | * (under the project TAO & TAO2); |
20 | * 2008-2010 (update and modification) Deutsche Institut für Internationale Pädagogische Forschung |
21 | * (under the project TAO-TRANSFER); |
22 | * 2009-2012 (update and modification) Public Research Centre Henri Tudor |
23 | * (under the project TAO-SUSTAIN & TAO-DEV); |
24 | * 2013 (update and modification) Open Assessment Technologies SA; |
25 | */ |
26 | |
27 | namespace oat\generis\model\kernel\uri; |
28 | |
29 | use oat\oatbox\service\ConfigurableService; |
30 | |
31 | /** |
32 | * UriProvider implementation based on an advanced key value storage |
33 | * |
34 | * @access public |
35 | * @author Joel Bout, <joel@taotesting.com> |
36 | * @package generis |
37 | */ |
38 | class Bin2HexUriProvider extends ConfigurableService implements UriProvider |
39 | { |
40 | public const OPTION_NAMESPACE = 'namespace'; |
41 | |
42 | /** |
43 | * Generates a URI based on a serial stored in the database. |
44 | * |
45 | * @access public |
46 | * @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu> |
47 | * @return string |
48 | * @throws UriProviderException |
49 | */ |
50 | public function provide() |
51 | { |
52 | return $this->getOption(self::OPTION_NAMESPACE) . uniqid('i') . date('YmdHis') |
53 | . bin2hex(openssl_random_pseudo_bytes(4)); |
54 | } |
55 | } |