Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
SharedStimulusResourceSpecification | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
3 | |
100.00% |
1 / 1 |
isSatisfiedBy | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
3 |
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) 2020 (original work) Open Assessment Technologies SA; |
19 | */ |
20 | |
21 | declare(strict_types=1); |
22 | |
23 | namespace oat\taoMediaManager\model\sharedStimulus\specification; |
24 | |
25 | use common_Exception; |
26 | use core_kernel_classes_EmptyProperty; |
27 | use core_kernel_classes_Literal; |
28 | use core_kernel_classes_Resource; |
29 | use oat\generis\model\OntologyAwareTrait; |
30 | use oat\oatbox\service\ConfigurableService; |
31 | use oat\taoMediaManager\model\MediaService; |
32 | use oat\taoMediaManager\model\TaoMediaOntology; |
33 | |
34 | class SharedStimulusResourceSpecification extends ConfigurableService |
35 | { |
36 | use OntologyAwareTrait; |
37 | |
38 | /** |
39 | * @throws common_Exception |
40 | */ |
41 | public function isSatisfiedBy(core_kernel_classes_Resource $resource): bool |
42 | { |
43 | try { |
44 | $propertyValue = $resource->getUniquePropertyValue( |
45 | $this->getProperty(TaoMediaOntology::PROPERTY_MIME_TYPE) |
46 | ); |
47 | |
48 | if ($propertyValue instanceof core_kernel_classes_Literal) { |
49 | return $propertyValue->literal === MediaService::SHARED_STIMULUS_MIME_TYPE; |
50 | } |
51 | } catch (core_kernel_classes_EmptyProperty $exception) { |
52 | } |
53 | |
54 | return false; |
55 | } |
56 | } |