TwigSyntax::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 9.4285
cc 3
eloc 4
nc 2
nop 1
crap 3
1
<?php
2
namespace Boekkooi\Bundle\TwigJackBundle\Validator\Constraint;
3
4
use Symfony\Component\Validator\Constraint;
5
use Symfony\Component\Validator\Exception\InvalidOptionsException;
6
7
/**
8
 * @author Warnar Boekkooi <[email protected]>
9
 */
10
class TwigSyntax extends Constraint
11
{
12
    public $message = 'This value is not a valid twig template.';
13
    public $parse = true;
14
    public $environment = null;
15
16 6
    public function __construct($options = null)
17
    {
18 6
        parent::__construct($options);
19
20 4
        if ($this->environment !== null && !$this->environment instanceof \Twig_Environment) {
21 1
            throw new InvalidOptionsException(sprintf('Option "environment" must be null or a Twig_Environment instance for constraint %s', __CLASS__), array('environment'));
22
        }
23 3
    }
24
25 1
    public function validatedBy()
26
    {
27 1
        return 'TwigSyntaxValidator';
28
    }
29
}
30