Code Coverage  | 
      ||||||||||
Lines  | 
       Functions and Methods  | 
       Classes and Traits  | 
      ||||||||
| Total |         | 
       0.00%  | 
       0 / 17  | 
               | 
       0.00%  | 
       0 / 1  | 
       CRAP |         | 
       0.00%  | 
       0 / 1  | 
      
| ValidationRulesMapper |         | 
       0.00%  | 
       0 / 17  | 
               | 
       0.00%  | 
       0 / 1  | 
       6 |         | 
       0.00%  | 
       0 / 1  | 
      
| getValidator |         | 
       0.00%  | 
       0 / 17  | 
               | 
       0.00%  | 
       0 / 1  | 
       6 | |||
| 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\taoQtiItem\model\import\Validator; | 
| 24 | |
| 25 | use oat\oatbox\service\ConfigurableService; | 
| 26 | use oat\taoQtiItem\model\import\Validator\Rule\IsIntegerRule; | 
| 27 | use oat\taoQtiItem\model\import\Validator\Rule\LessOrEqualRule; | 
| 28 | use oat\taoQtiItem\model\import\Validator\Rule\MinOccurrencesRule; | 
| 29 | use oat\taoQtiItem\model\import\Validator\Rule\NumericOrEmptyRule; | 
| 30 | use oat\taoQtiItem\model\import\Validator\Rule\OneOfColumnsOrEmptyRule; | 
| 31 | use oat\taoQtiItem\model\import\Validator\Rule\OneOfRule; | 
| 32 | use oat\taoQtiItem\model\import\Validator\Rule\OptionalRule; | 
| 33 | use oat\taoQtiItem\model\import\Validator\Rule\QtiCompatibleXmlRule; | 
| 34 | use oat\taoQtiItem\model\import\Validator\Rule\RequireRule; | 
| 35 | use oat\taoQtiItem\model\import\Validator\Rule\StrictNoGapsRule; | 
| 36 | use oat\taoQtiItem\model\import\Validator\Rule\StrictNumericRule; | 
| 37 | use oat\taoQtiItem\model\import\Validator\Rule\SupportedLanguageRule; | 
| 38 | use oat\taoQtiItem\model\import\Validator\Rule\ValidationRuleInterface; | 
| 39 | |
| 40 | class ValidationRulesMapper extends ConfigurableService | 
| 41 | { | 
| 42 | public function getValidator(string $key): ?ValidationRuleInterface | 
| 43 | { | 
| 44 | $mapper = [ | 
| 45 | 'is_integer' => IsIntegerRule::class, | 
| 46 | 'language' => SupportedLanguageRule::class, | 
| 47 | 'less_or_equals' => LessOrEqualRule::class, | 
| 48 | 'no_gaps' => StrictNoGapsRule::class, | 
| 49 | 'one_of' => OneOfRule::class, | 
| 50 | 'optional' => OptionalRule::class, | 
| 51 | 'required' => RequireRule::class, | 
| 52 | 'qtiXmlString' => QtiCompatibleXmlRule::class, | 
| 53 | 'strict_numeric' => StrictNumericRule::class, | 
| 54 | 'numeric_or_empty' => NumericOrEmptyRule::class, | 
| 55 | 'min_occurrences' => MinOccurrencesRule::class, | 
| 56 | 'one_of_columns_or_empty' => OneOfColumnsOrEmptyRule::class, | 
| 57 | ]; | 
| 58 | |
| 59 | if (isset($mapper[$key])) { | 
| 60 | return $this->getServiceLocator()->get($mapper[$key]); | 
| 61 | } | 
| 62 | |
| 63 | return null; | 
| 64 | } | 
| 65 | } |