DateRange   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 17
ccs 0
cts 7
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 3
1
<?php
2
/**
3
 * Created by Michaël Perrin
4
 *
5
 * Source: http://www.michaelperrin.fr/2013/03/19/range-date-validator-for-symfony2/
6
 */
7
8
namespace AppBundle\Validator\Constraints;
9
10
use Symfony\Component\Validator\Constraint;
11
use Symfony\Component\Validator\Exception\MissingOptionsException;
12
13
/**
14
 * @Annotation
15
 */
16
class DateRange extends Constraint
17
{
18
    public $minMessage = 'This date should be greater than {{ limit }}.';
19
    public $maxMessage = 'This date should be less than {{ limit }}.';
20
    public $invalidMessage = 'This value should be a valid date.';
21
    public $min;
22
    public $max;
23
24
    public function __construct($options = null)
25
    {
26
        parent::__construct($options);
27
28
        if (null === $this->min && null === $this->max) {
29
            throw new MissingOptionsException('Either option "min" or "max" must be given for constraint ' . __CLASS__, array('min', 'max'));
30
        }
31
    }
32
}
33