Completed
Push — master ( 93ef1f...d80a95 )
by Christophe
13:13
created

Regex::resolve()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4286
cc 2
eloc 5
nc 2
nop 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
18
/**
19
 * @Annotation
20
 *
21
 * @author Ener-Getick <[email protected]>
22
 */
23
class Regex extends BaseRegex
24
{
25
    use ResolverTrait;
26
27
    private $resolved;
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function validatedBy()
33
    {
34
        return 'Symfony\Component\Validator\Constraints\RegexValidator';
35
    }
36
37
    public function resolve(ContainerInterface $container)
38
    {
39
        if ($this->resolved) {
40
            return;
41
        }
42
        $this->pattern = $this->resolveValue($container, $this->pattern);
43
        $this->resolved = true;
44
    }
45
}
46