FieldDependency   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 30
ccs 0
cts 6
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A macro() 0 4 1
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