FieldValueDependency   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
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 36
ccs 0
cts 10
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 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 has a specific value.
9
 */
10
class FieldValueDependency implements RuleCondition
11
{
12
    const VALUE_EQUAL = '=';
13
    const VALUE_NOT_EQUAL = '!=';
14
15
    /**
16
     * Dependent field
17
     * @var string
18
     */
19
    public $field;
20
21
    /**
22
     * @var string
23
     */
24
    public $condition;
25
26
    /**
27
     * @var mixed
28
     */
29
    public $value;
30
31
    public function __construct($field, $condition = self::VALUE_EQUAL, $value)
32
    {
33
        $this->field = FormHelper::getFormName($field);
34
        $this->condition = $condition;
35
        $this->value = $value;
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function macro()
42
    {
43
        return 'field_value_dependency';
44
    }
45
}
46