Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
20.00% |
2 / 10 |
|
25.00% |
1 / 4 |
CRAP | |
0.00% |
0 / 1 |
| UpdateMetadataInput | |
20.00% |
2 / 10 |
|
25.00% |
1 / 4 |
12.19 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getResource | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getMetadata | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| jsonSerialize | |
0.00% |
0 / 6 |
|
0.00% |
0 / 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) 2022 (original work) Open Assessment Technologies SA; |
| 19 | */ |
| 20 | |
| 21 | declare(strict_types=1); |
| 22 | |
| 23 | namespace oat\taoQtiItem\model\input; |
| 24 | |
| 25 | use core_kernel_classes_Resource; |
| 26 | use JsonSerializable; |
| 27 | use oat\taoQtiItem\model\qti\metadata\simple\SimpleMetadataValue; |
| 28 | |
| 29 | class UpdateMetadataInput implements JsonSerializable |
| 30 | { |
| 31 | public const PROPERTY_URI = 'propertyUri'; |
| 32 | public const RESOURCE_URI = 'resourceUri'; |
| 33 | public const VALUE = 'value'; |
| 34 | |
| 35 | public const VALID_PROPERTIES = [ |
| 36 | UpdateMetadataInput::PROPERTY_URI, |
| 37 | UpdateMetadataInput::RESOURCE_URI, |
| 38 | UpdateMetadataInput::VALUE, |
| 39 | ]; |
| 40 | |
| 41 | private core_kernel_classes_Resource $resource; |
| 42 | private SimpleMetadataValue $metadata; |
| 43 | |
| 44 | public function __construct(core_kernel_classes_Resource $resource, SimpleMetadataValue $metadata) |
| 45 | { |
| 46 | $this->resource = $resource; |
| 47 | $this->metadata = $metadata; |
| 48 | } |
| 49 | |
| 50 | public function getResource(): core_kernel_classes_Resource |
| 51 | { |
| 52 | return $this->resource; |
| 53 | } |
| 54 | |
| 55 | public function getMetadata(): SimpleMetadataValue |
| 56 | { |
| 57 | return $this->metadata; |
| 58 | } |
| 59 | |
| 60 | public function jsonSerialize(): array |
| 61 | { |
| 62 | $path = $this->metadata->getPath(); |
| 63 | |
| 64 | return [ |
| 65 | self::RESOURCE_URI => $this->resource->getUri(), |
| 66 | self::PROPERTY_URI => end($path), |
| 67 | self::VALUE => $this->getMetadata()->getValue(), |
| 68 | ]; |
| 69 | } |
| 70 | } |