Regex::validatedBy()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
/*
4
 * This file is part of the FOSRestBundle package.
5
 *
6
 * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace FOS\RestBundle\Validator\Constraints;
13
14
use FOS\RestBundle\Util\ResolverTrait;
15
use Symfony\Component\DependencyInjection\ContainerInterface;
16
use Symfony\Component\Validator\Constraints\Regex as BaseRegex;
17
use Symfony\Component\Validator\Constraints\RegexValidator;
18
19
/**
20
 * @Annotation
21
 *
22
 * @author Ener-Getick <[email protected]>
23
 */
24
class Regex extends BaseRegex implements ResolvableConstraintInterface
25
{
26
    use ResolverTrait;
27
28
    private $resolved;
29
30
    /**
31
     * {@inheritdoc}
32
     */
33 6
    public function validatedBy(): string
34
    {
35 6
        return RegexValidator::class;
36
    }
37
38 6
    public function resolve(ContainerInterface $container): void
39
    {
40 6
        if ($this->resolved) {
41
            return;
42
        }
43 6
        $this->pattern = $this->resolveValue($container, $this->pattern);
44 6
        $this->resolved = true;
45 6
    }
46
}
47