Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
9 / 9 |
|
100.00% |
4 / 4 |
CRAP | |
100.00% |
1 / 1 |
DependsOnPropertyCollection | |
100.00% |
9 / 9 |
|
100.00% |
4 / 4 |
5 | |
100.00% |
1 / 1 |
isEqual | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getPropertyUris | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
1 | |||
isEmpty | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
areArraysEqual | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 |
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\generis\model\resource; |
24 | |
25 | use ArrayIterator; |
26 | use core_kernel_classes_Property; |
27 | |
28 | /** |
29 | * @method core_kernel_classes_Property|null current() |
30 | */ |
31 | class DependsOnPropertyCollection extends ArrayIterator |
32 | { |
33 | public function isEqual(DependsOnPropertyCollection $dependsOnPropertyCollection): bool |
34 | { |
35 | return $this->areArraysEqual($this->getPropertyUris(), $dependsOnPropertyCollection->getPropertyUris()); |
36 | } |
37 | |
38 | public function getPropertyUris(): array |
39 | { |
40 | return array_map( |
41 | static function (core_kernel_classes_Property $property) { |
42 | return $property->getUri(); |
43 | }, |
44 | $this->getArrayCopy() |
45 | ); |
46 | } |
47 | |
48 | public function isEmpty(): bool |
49 | { |
50 | return $this->count() === 0; |
51 | } |
52 | |
53 | private function areArraysEqual(array $array1, array $array2): bool |
54 | { |
55 | return empty(array_diff($array1, $array2)) && empty(array_diff($array2, $array1)); |
56 | } |
57 | } |