Completed
Push — master ( 3b34b0...1f6e23 )
by Adrian
01:20
created

Matching   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A validate() 0 11 2
1
<?php
2
declare(strict_types=1);
3
namespace Sirius\Validation\Rule;
4
5
class Matching extends AbstractRule
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 = [
13
        0 => self::OPTION_ITEM
14
    ];
15
16 5
    public function validate($value, string $valueIdentifier = null):bool
17
    {
18 5
        $this->value = $value;
19 5
        if (isset($this->options[self::OPTION_ITEM])) {
20 3
            $this->success = ($value == $this->context->getItemValue($this->options[self::OPTION_ITEM]));
21
        } else {
22 2
            $this->success = true;
23
        }
24
25 5
        return $this->success;
26
    }
27
}
28