Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
DeliveryValidatorFactory
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
3
100.00% covered (success)
100.00%
1 / 1
 createMultiple
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
3
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
21namespace oat\taoDeliveryRdf\model\validation;
22
23use oat\oatbox\service\ConfigurableService;
24use oat\taoDeliveryRdf\model\DeliveryAssemblyService;
25use tao_helpers_form_FormFactory;
26use tao_helpers_Uri;
27
28class DeliveryValidatorFactory extends ConfigurableService
29{
30    private const VALIDATORS =
31        [
32            DeliveryAssemblyService::PROPERTY_ASSESSMENT_PROJECT_ID => [
33                [
34                    'AlphaNum',
35                    [
36                        'allow_punctuation' => true
37                    ]
38                ]
39            ],
40            DeliveryAssemblyService::PROPERTY_START => [
41                [
42                    'DateTime'
43                ]
44            ]
45        ];
46
47    public function createMultiple(): array
48    {
49        $output = [];
50
51        foreach (self::VALIDATORS as $field => $validators) {
52            $index = tao_helpers_Uri::encode($field);
53            $output[$index] = [];
54
55            foreach ($validators as $validator) {
56                $output[$index][] = tao_helpers_form_FormFactory::getValidator(...$validator);
57            }
58        }
59
60        return $output;
61    }
62}