Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
92.86% |
13 / 14 |
|
66.67% |
2 / 3 |
CRAP | |
0.00% |
0 / 1 |
UpdateTranslationCommand | |
92.86% |
13 / 14 |
|
66.67% |
2 / 3 |
4.01 | |
0.00% |
0 / 1 |
__construct | |
91.67% |
11 / 12 |
|
0.00% |
0 / 1 |
2.00 | |||
getResourceUri | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getProgressUri | |
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) 2024 (original work) Open Assessment Technologies SA; |
19 | */ |
20 | |
21 | declare(strict_types=1); |
22 | |
23 | namespace oat\tao\model\Translation\Command; |
24 | |
25 | use oat\tao\model\TaoOntology; |
26 | use oat\tao\model\Translation\Exception\ResourceTranslationException; |
27 | |
28 | class UpdateTranslationCommand |
29 | { |
30 | private string $resourceUri; |
31 | private string $progressUri; |
32 | |
33 | public function __construct(string $resourceUri, string $progressUri) |
34 | { |
35 | if ( |
36 | !in_array( |
37 | $progressUri, |
38 | [ |
39 | TaoOntology::PROPERTY_VALUE_TRANSLATION_PROGRESS_PENDING, |
40 | TaoOntology::PROPERTY_VALUE_TRANSLATION_PROGRESS_TRANSLATING, |
41 | TaoOntology::PROPERTY_VALUE_TRANSLATION_PROGRESS_TRANSLATED, |
42 | ], |
43 | true |
44 | ) |
45 | ) { |
46 | throw new ResourceTranslationException(sprintf('Translation status %s is not allowed', $progressUri)); |
47 | } |
48 | |
49 | $this->resourceUri = $resourceUri; |
50 | $this->progressUri = $progressUri; |
51 | } |
52 | |
53 | public function getResourceUri(): string |
54 | { |
55 | return $this->resourceUri; |
56 | } |
57 | |
58 | public function getProgressUri(): string |
59 | { |
60 | return $this->progressUri; |
61 | } |
62 | } |