Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 30 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| IMSPciValidator | |
0.00% |
0 / 30 |
|
0.00% |
0 / 3 |
12 | |
0.00% |
0 / 1 |
| getConstraints | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
| getAssetConstraints | |
0.00% |
0 / 17 |
|
0.00% |
0 / 1 |
2 | |||
| isOptionalConstraint | |
0.00% |
0 / 8 |
|
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) 2017 (original work) Open Assessment Technologies SA; |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | namespace oat\qtiItemPci\model\portableElement\validator; |
| 23 | |
| 24 | use oat\taoQtiItem\model\portableElement\validator\PortableElementModelValidator; |
| 25 | use oat\taoQtiItem\model\portableElement\validator\Validator; |
| 26 | |
| 27 | class IMSPciValidator extends PortableElementModelValidator |
| 28 | { |
| 29 | /** |
| 30 | * Return model constraint validators |
| 31 | * |
| 32 | * @return array |
| 33 | */ |
| 34 | public function getConstraints() |
| 35 | { |
| 36 | $pciConstraints = [ |
| 37 | 'response' => [ Validator::isArray, Validator::NotEmpty ], |
| 38 | 'creator' => [ Validator::isArray ] |
| 39 | ]; |
| 40 | return array_merge($pciConstraints, parent::getConstraints()); |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * Return asset constraints |
| 45 | * |
| 46 | * @param $key |
| 47 | * @return array |
| 48 | */ |
| 49 | public function getAssetConstraints($key) |
| 50 | { |
| 51 | $pciConstraints = [ |
| 52 | 'runtime' => [ |
| 53 | 'modules', |
| 54 | 'config', |
| 55 | 'src' |
| 56 | ], |
| 57 | 'creator' => [ |
| 58 | 'icon', |
| 59 | 'hook', |
| 60 | 'libraries', |
| 61 | 'stylesheets', |
| 62 | 'mediaFiles', |
| 63 | 'src' |
| 64 | ] |
| 65 | ]; |
| 66 | |
| 67 | $this->assetConstraints = array_merge($this->assetConstraints, $pciConstraints); |
| 68 | return parent::getAssetConstraints($key); |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * Return optional constraints |
| 73 | * |
| 74 | * @param $key |
| 75 | * @param $constraint |
| 76 | * @return bool |
| 77 | */ |
| 78 | public function isOptionalConstraint($key, $constraint) |
| 79 | { |
| 80 | $optional = [ |
| 81 | 'creator' => [ |
| 82 | 'stylesheets', |
| 83 | 'mediaFiles', |
| 84 | ] |
| 85 | ]; |
| 86 | |
| 87 | $this->optional = array_merge($optional, $this->optional); |
| 88 | return parent::isOptionalConstraint($key, $constraint); |
| 89 | } |
| 90 | } |