Completed
Push — master ( aeb11c...f98da5 )
by Adrian
02:32
created

Match   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 4
Bugs 0 Features 1
Metric Value
wmc 2
c 4
b 0
f 1
lcom 1
cbo 2
dl 0
loc 24
ccs 7
cts 7
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A validate() 0 11 2
1
<?php
2
namespace Sirius\Validation\Rule;
3
4
class Match extends AbstractRule
5
{
6
7
    const OPTION_ITEM = 'item';
8
9
    const MESSAGE = 'This input does not match {item}';
10
    const LABELED_MESSAGE = '{label} does not match {item}';
11
12
    protected $optionsIndexMap = array(
13
        0 => self::OPTION_ITEM
14
    );
15
16 3
    public function validate($value, $valueIdentifier = null)
17
    {
18 3
        $this->value = $value;
19 3
        if (isset($this->options[self::OPTION_ITEM])) {
20 2
            $this->success = ($value == $this->context->getItemValue($this->options[self::OPTION_ITEM]));
21 2
        } else {
22 1
            $this->success = true;
23
        }
24
25 3
        return $this->success;
26
    }
27
}
28