Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 12 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| QtiTimeStorageObjectDecodingTrait | |
0.00% |
0 / 12 |
|
0.00% |
0 / 2 |
42 | |
0.00% |
0 / 1 |
| decodeTimeline | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
12 | |||
| decodeAdjustmentMap | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
12 | |||
| 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) 2020 (original work) Open Assessment Technologies SA ; |
| 19 | */ |
| 20 | |
| 21 | namespace oat\taoQtiTest\models\runner\time\storageFormat; |
| 22 | |
| 23 | use oat\taoQtiTest\models\runner\time\AdjustmentMap; |
| 24 | use oat\taoQtiTest\models\runner\time\QtiTimeLine; |
| 25 | use oat\taoTests\models\runner\time\TimeLine; |
| 26 | use oat\taoTests\models\runner\time\TimerAdjustmentMapInterface; |
| 27 | |
| 28 | trait QtiTimeStorageObjectDecodingTrait |
| 29 | { |
| 30 | private function decodeTimeline(array $data): array |
| 31 | { |
| 32 | if ( |
| 33 | array_key_exists(self::STORAGE_KEY_TIME_LINE, $data) |
| 34 | && !$data[self::STORAGE_KEY_TIME_LINE] instanceof TimeLine |
| 35 | ) { |
| 36 | $timeLine = new QtiTimeLine(); |
| 37 | $timeLine->fromArray($data[self::STORAGE_KEY_TIME_LINE]); |
| 38 | $data[self::STORAGE_KEY_TIME_LINE] = $timeLine; |
| 39 | } |
| 40 | |
| 41 | return $data; |
| 42 | } |
| 43 | |
| 44 | private function decodeAdjustmentMap(array $data): array |
| 45 | { |
| 46 | if ( |
| 47 | array_key_exists(self::STORAGE_KEY_TIMER_ADJUSTMENT_MAP, $data) |
| 48 | && !$data[self::STORAGE_KEY_TIMER_ADJUSTMENT_MAP] instanceof TimerAdjustmentMapInterface |
| 49 | ) { |
| 50 | $map = new AdjustmentMap(); |
| 51 | $map->fromArray($data[self::STORAGE_KEY_TIMER_ADJUSTMENT_MAP]); |
| 52 | $data[self::STORAGE_KEY_TIMER_ADJUSTMENT_MAP] = $map; |
| 53 | } |
| 54 | |
| 55 | return $data; |
| 56 | } |
| 57 | } |