FieldDependency::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 0
cts 4
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
crap 2
1
<?php
2
namespace Boekkooi\Bundle\JqueryValidationBundle\Form\Rule\Condition;
3
4
use Boekkooi\Bundle\JqueryValidationBundle\Form\RuleCondition;
5
use Boekkooi\Bundle\JqueryValidationBundle\Form\Util\FormHelper;
6
7
/**
8
 * Class used to indicate that a rule will only be validated when a field other field is valid.
9
 */
10
class FieldDependency implements RuleCondition
11
{
12
    const FIELD_VALID = '=';
13
    const FIELD_INVALID = '!';
14
15
    /**
16
     * Dependent field
17
     * @var string
18
     */
19
    public $field;
20
21
    /**
22
     * @var string
23
     */
24
    public $condition;
25
26
    public function __construct($field, $condition = self::FIELD_VALID)
27
    {
28
        $this->field = FormHelper::getFormName($field);
29
        $this->condition = $condition;
30
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35
    public function macro()
36
    {
37
        return 'field_dependency';
38
    }
39
}
40