Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
10 / 10 |
|
100.00% |
8 / 8 |
CRAP | |
100.00% |
1 / 1 |
DeliveryDeleteRequest | |
100.00% |
10 / 10 |
|
100.00% |
8 / 8 |
8 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getDeliveryResource | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
isDeliveryRemovalRequested | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
isExecutionsRemovalRequested | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
isRecursive | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setIsRecursive | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
setDeliveryExecutionsOnly | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
hasInScope | |
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) 2018 (original work) Open Assessment Technologies SA; |
19 | * |
20 | */ |
21 | |
22 | declare(strict_types=1); |
23 | |
24 | namespace oat\taoDeliveryRdf\model\Delete; |
25 | |
26 | use core_kernel_classes_Resource as KernelResource; |
27 | |
28 | class DeliveryDeleteRequest |
29 | { |
30 | private const SCOPE_DELIVERY = 1 << 0; |
31 | private const SCOPE_EXECUTIONS = 1 << 2; |
32 | private const SCOPE_RESOURCES = 1 << 3; |
33 | |
34 | /** @var string */ |
35 | private $deliveryId; |
36 | |
37 | /** @var int */ |
38 | private $scope = self::SCOPE_DELIVERY | self::SCOPE_EXECUTIONS; |
39 | |
40 | public function __construct(string $deliveryId) |
41 | { |
42 | $this->deliveryId = $deliveryId; |
43 | } |
44 | |
45 | public function getDeliveryResource(): KernelResource |
46 | { |
47 | return new KernelResource($this->deliveryId); |
48 | } |
49 | |
50 | public function isDeliveryRemovalRequested(): bool |
51 | { |
52 | return $this->hasInScope(self::SCOPE_DELIVERY); |
53 | } |
54 | |
55 | public function isExecutionsRemovalRequested(): bool |
56 | { |
57 | return $this->hasInScope(self::SCOPE_EXECUTIONS); |
58 | } |
59 | |
60 | public function isRecursive(): bool |
61 | { |
62 | return $this->hasInScope(self::SCOPE_RESOURCES); |
63 | } |
64 | |
65 | public function setIsRecursive(): self |
66 | { |
67 | $this->scope |= self::SCOPE_RESOURCES; |
68 | |
69 | return $this; |
70 | } |
71 | |
72 | public function setDeliveryExecutionsOnly(): self |
73 | { |
74 | $this->scope = self::SCOPE_EXECUTIONS; |
75 | |
76 | return $this; |
77 | } |
78 | |
79 | private function hasInScope(int $scope): bool |
80 | { |
81 | return (bool)($this->scope & $scope); |
82 | } |
83 | } |