Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
58.33% |
7 / 12 |
|
50.00% |
3 / 6 |
CRAP | |
0.00% |
0 / 1 |
| ClassificationMetadataValue | |
58.33% |
7 / 12 |
|
50.00% |
3 / 6 |
12.63 | |
0.00% |
0 / 1 |
| __construct | |
57.14% |
4 / 7 |
|
0.00% |
0 / 1 |
3.71 | |||
| getEntries | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getPath | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getLanguage | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getResourceIdentifier | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getValue | |
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) 2017 Open Assessment Technologies SA |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | namespace oat\taoQtiItem\model\qti\metadata\imsManifest\classificationMetadata; |
| 23 | |
| 24 | use oat\tao\model\metadata\exception\writer\MetadataWriterException; |
| 25 | |
| 26 | class ClassificationMetadataValue implements ClassificationValue |
| 27 | { |
| 28 | /** |
| 29 | * @var ClassificationSourceMetadataValue |
| 30 | */ |
| 31 | protected $source; |
| 32 | |
| 33 | /** |
| 34 | * @var ClassificationEntryMetadataValue[] |
| 35 | */ |
| 36 | protected $entries; |
| 37 | |
| 38 | /** |
| 39 | * ClassificationMetadataValue constructor. |
| 40 | * |
| 41 | * @param ClassificationSourceMetadataValue $source |
| 42 | * @param array $entries |
| 43 | * @throws MetadataWriterException |
| 44 | */ |
| 45 | public function __construct(ClassificationSourceMetadataValue $source, array $entries) |
| 46 | { |
| 47 | foreach ($entries as $entry) { |
| 48 | if (! $entry instanceof ClassificationEntryMetadataValue) { |
| 49 | throw new MetadataWriterException( |
| 50 | __('Classification entries have to be an instance of ClassificationEntryMetadataValue') |
| 51 | ); |
| 52 | } |
| 53 | } |
| 54 | $this->source = $source; |
| 55 | $this->entries = $entries; |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * Get all classification metadata entries |
| 60 | * |
| 61 | * @return ClassificationEntryMetadataValue[] |
| 62 | */ |
| 63 | public function getEntries() |
| 64 | { |
| 65 | return $this->entries; |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Get source classification path |
| 70 | * |
| 71 | * @return array |
| 72 | */ |
| 73 | public function getPath() |
| 74 | { |
| 75 | return $this->source->getPath(); |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * Get language classification source |
| 80 | * |
| 81 | * @return string |
| 82 | */ |
| 83 | public function getLanguage() |
| 84 | { |
| 85 | return $this->source->getLanguage(); |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * Get resource identifier associated to classification source |
| 90 | * |
| 91 | * @return string |
| 92 | */ |
| 93 | public function getResourceIdentifier() |
| 94 | { |
| 95 | return $this->source->getResourceIdentifier(); |
| 96 | } |
| 97 | |
| 98 | /** |
| 99 | * Get the value of the classification source |
| 100 | * |
| 101 | * @return string |
| 102 | */ |
| 103 | public function getValue() |
| 104 | { |
| 105 | return $this->source->getValue(); |
| 106 | } |
| 107 | } |