Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 20
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
ItemIdentifierValidatorServiceProvider
0.00% covered (danger)
0.00%
0 / 20
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 __invoke
0.00% covered (danger)
0.00%
0 / 20
0.00% covered (danger)
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) 2022 (original work) Open Assessment Technologies SA;
19 */
20
21declare(strict_types=1);
22
23namespace oat\taoQtiItem\model\qti\ServiceProvider;
24
25use oat\generis\model\DependencyInjection\ContainerServiceProviderInterface;
26use oat\tao\model\featureFlag\FeatureFlagChecker;
27use oat\taoQtiItem\model\qti\validator\ItemIdentifierValidator;
28use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
29
30use function Symfony\Component\DependencyInjection\Loader\Configurator\env;
31use function Symfony\Component\DependencyInjection\Loader\Configurator\service;
32
33class ItemIdentifierValidatorServiceProvider implements ContainerServiceProviderInterface
34{
35    public function __invoke(ContainerConfigurator $configurator): void
36    {
37        $services = $configurator->services();
38        $parameters = $configurator->parameters();
39
40        /**
41         * Please specify the QTI Identifier Validator Pattern that will be used to validate the item identifier
42         * Ex: /^[a-zA-Z_]{1}[a-zA-Z0-9_-]*$/u
43         * The Default is /^[a-zA-Z_]{1}[a-zA-Z0-9_\.-]*$/u
44         */
45        $parameters->set(
46            ItemIdentifierValidator::DEFAULT_PATTERN_PARAMETER_NAME,
47            ItemIdentifierValidator::DEFAULT_PATTERN
48        );
49
50        $services->set(ItemIdentifierValidator::class, ItemIdentifierValidator::class)
51            ->public()
52            ->args(
53                [
54                    service(FeatureFlagChecker::class),
55                    env(
56                        sprintf(
57                            'default:%s:%s',
58                            ItemIdentifierValidator::DEFAULT_PATTERN_PARAMETER_NAME,
59                            ItemIdentifierValidator::ENV_QTI_IDENTIFIER_VALIDATOR_PATTERN
60                        )
61                    )
62                ]
63            );
64    }
65}