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

Match::validate()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 11
ccs 7
cts 7
cp 1
rs 9.4285
cc 2
eloc 7
nc 2
nop 2
crap 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