Pattern::configureOptions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 10
1
<?php
2
3
namespace JBen87\ParsleyBundle\Constraint\Constraints;
4
5
use JBen87\ParsleyBundle\Constraint\Constraint;
6
use Symfony\Component\OptionsResolver\OptionsResolver;
7
8
class Pattern extends Constraint
9
{
10
    /**
11
     * @var string
12
     */
13
    private $pattern;
14
15
    /**
16
     * @param array $options
17
     */
18 7
    public function __construct(array $options = [])
19
    {
20 7
        parent::__construct($options);
21
22 5
        $this->pattern = $options['pattern'];
23 5
    }
24
25
    /**
26
     * @inheritdoc
27
     */
28 2
    protected function getAttribute(): string
29
    {
30 2
        return 'data-parsley-pattern';
31
    }
32
33
    /**
34
     * @inheritdoc
35
     */
36 2
    protected function getValue(): string
37
    {
38 2
        return $this->pattern;
39
    }
40
41
    /**
42
     * @inheritdoc
43
     */
44 7
    protected function configureOptions(OptionsResolver $resolver): void
45
    {
46
        $resolver
47 7
            ->setRequired(['pattern'])
48 7
            ->setAllowedTypes('pattern', ['string'])
49
        ;
50 7
    }
51
}
52