Max   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 41
ccs 11
cts 11
cp 1
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getValue() 0 3 1
A getAttribute() 0 3 1
A __construct() 0 5 1
A configureOptions() 0 5 1
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 Max extends Constraint
9
{
10
    /**
11
     * @var int
12
     */
13
    private $max;
14
15
    /**
16
     * @param array $options
17
     */
18 5
    public function __construct(array $options = [])
19
    {
20 5
        parent::__construct($options);
21
22 3
        $this->max = $options['max'];
23 3
    }
24
25
    /**
26
     * @inheritdoc
27
     */
28 2
    protected function getAttribute(): string
29
    {
30 2
        return 'data-parsley-max';
31
    }
32
33
    /**
34
     * @inheritdoc
35
     */
36 2
    protected function getValue(): string
37
    {
38 2
        return (string) $this->max;
39
    }
40
41
    /**
42
     * @inheritdoc
43
     */
44 5
    protected function configureOptions(OptionsResolver $resolver): void
45
    {
46
        $resolver
47 5
            ->setRequired(['max'])
48 5
            ->setAllowedTypes('max', ['int'])
49
        ;
50 5
    }
51
}
52