Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
85.71% |
6 / 7 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| RemoteListClassSpecification | |
85.71% |
6 / 7 |
|
50.00% |
1 / 2 |
4.05 | |
0.00% |
0 / 1 |
| isSatisfiedBy | |
83.33% |
5 / 6 |
|
0.00% |
0 / 1 |
3.04 | |||
| getListClassSpecification | |
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) 2021 (original work) Open Assessment Technologies SA; |
| 19 | */ |
| 20 | |
| 21 | declare(strict_types=1); |
| 22 | |
| 23 | namespace oat\tao\model\Lists\Business\Specification; |
| 24 | |
| 25 | use core_kernel_classes_Class; |
| 26 | use oat\oatbox\service\ConfigurableService; |
| 27 | use oat\tao\model\Specification\ClassSpecificationInterface; |
| 28 | use oat\tao\model\Lists\Business\Service\RemoteSourcedListOntology; |
| 29 | |
| 30 | class RemoteListClassSpecification extends ConfigurableService implements ClassSpecificationInterface |
| 31 | { |
| 32 | public function isSatisfiedBy(core_kernel_classes_Class $class): bool |
| 33 | { |
| 34 | if (!$this->getListClassSpecification()->isSatisfiedBy($class)) { |
| 35 | return false; |
| 36 | } |
| 37 | |
| 38 | $propertyType = $class->getOnePropertyValue( |
| 39 | $class->getProperty(RemoteSourcedListOntology::PROPERTY_LIST_TYPE) |
| 40 | ); |
| 41 | |
| 42 | return $propertyType !== null && $propertyType->getUri() === RemoteSourcedListOntology::LIST_TYPE_REMOTE; |
| 43 | } |
| 44 | |
| 45 | private function getListClassSpecification(): ClassSpecificationInterface |
| 46 | { |
| 47 | return $this->getServiceManager()->getContainer()->get(ListClassSpecification::class); |
| 48 | } |
| 49 | } |