Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
10 / 10 |
|
100.00% |
4 / 4 |
CRAP | |
100.00% |
1 / 1 |
SimpleLock | |
100.00% |
10 / 10 |
|
100.00% |
4 / 4 |
7 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
4 | |||
getResource | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getCreationTime | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getOwnerId | |
100.00% |
1 / 1 |
|
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) 2013 Open Assessment Technologies S.A. |
19 | * |
20 | */ |
21 | |
22 | namespace oat\tao\model\lock\implementation; |
23 | |
24 | use oat\tao\model\lock\Lock; |
25 | use core_kernel_classes_Resource; |
26 | use common_exception_InconsistentData; |
27 | |
28 | /** |
29 | * Implements Lock using a simple property in the ontology for the lock storage |
30 | * |
31 | **/ |
32 | class SimpleLock implements Lock |
33 | { |
34 | /** |
35 | * the resource being locked |
36 | * @var core_kernel_classe_Resource |
37 | */ |
38 | private $resource; |
39 | |
40 | /** |
41 | * the owner of the lock |
42 | * @var string |
43 | */ |
44 | private $ownerId; |
45 | |
46 | /** |
47 | * the epoch when the lock was set up |
48 | * @var string |
49 | */ |
50 | private $epoch; |
51 | |
52 | /** |
53 | * |
54 | * @author "Patrick Plichart, <patrick@taotesting.com>" |
55 | * @param core_kernel_classes_Resource $resource |
56 | * @param core_kernel_classes_Resource $owner |
57 | * @param float $epoch |
58 | */ |
59 | public function __construct(core_kernel_classes_Resource $resource, $ownerId, $epoch) |
60 | { |
61 | if (!is_string($ownerId)) { |
62 | if (is_object($ownerId) && $ownerId instanceof \core_kernel_classes_Resource) { |
63 | $ownerId = $ownerId->getUri(); |
64 | } else { |
65 | throw new \common_exception_Error('Unsupported OwnerId'); |
66 | } |
67 | } |
68 | $this->resource = $resource; |
69 | $this->ownerId = $ownerId; |
70 | $this->epoch = $epoch; |
71 | } |
72 | |
73 | /** |
74 | * |
75 | * @author "Patrick Plichart, <patrick@taotesting.com>" |
76 | * @return core_kernel_classes_Resource |
77 | */ |
78 | public function getResource() |
79 | { |
80 | return $this->resource; |
81 | } |
82 | |
83 | /** |
84 | * |
85 | * @author "Patrick Plichart, <patrick@taotesting.com>" |
86 | */ |
87 | public function getCreationTime() |
88 | { |
89 | return $this->epoch; |
90 | } |
91 | |
92 | public function getOwnerId() |
93 | { |
94 | return $this->ownerId; |
95 | } |
96 | } |