Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
RemoteListPropertySpecification
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
3 / 3
5
100.00% covered (success)
100.00%
1 / 1
 isSatisfiedBy
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
2
 getPropertyRange
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
2
 getRemoteListClassSpecification
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
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
21declare(strict_types=1);
22
23namespace oat\tao\model\Lists\Business\Specification;
24
25use core_kernel_classes_Class;
26use oat\tao\model\Specification\ClassSpecificationInterface;
27use core_kernel_classes_Property;
28use oat\oatbox\service\ConfigurableService;
29use oat\tao\model\Specification\PropertySpecificationInterface;
30
31class RemoteListPropertySpecification extends ConfigurableService implements PropertySpecificationInterface
32{
33    /** @var core_kernel_classes_Class[]|null[] */
34    private $ranges = [];
35
36    public function isSatisfiedBy(core_kernel_classes_Property $property): bool
37    {
38        $class = $this->getPropertyRange($property);
39
40        if ($class === null) {
41            return false;
42        }
43
44        return $this->getRemoteListClassSpecification()->isSatisfiedBy($class);
45    }
46
47    private function getPropertyRange(core_kernel_classes_Property $property): ?core_kernel_classes_Class
48    {
49        $propertyUri = $property->getUri();
50
51        if (!isset($this->ranges[$propertyUri])) {
52            $this->ranges[$propertyUri] = $property->getRange();
53        }
54
55        return $this->ranges[$propertyUri];
56    }
57
58    private function getRemoteListClassSpecification(): ClassSpecificationInterface
59    {
60        return $this->getServiceManager()->getContainer()->get(RemoteListClassSpecification::class);
61    }
62}