Completed
Push — master ( 875683...f93a58 )
by Lee
02:09
created

NotSame   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 36
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A notSameAs() 0 6 1
A compare() 0 10 2
1
<?php
2
3
namespace Lavibi\Popoya;
4
5
class NotSame extends AbstractCompareValidator
6
{
7
    const E_SAME = 'same';
8
9
    protected $messages = [
10
        self::E_SAME => 'The given value is same with compared value.'
11
    ];
12
13
    /**
14
     * Set compared value
15
     *
16
     * @param $value
17
     *
18
     * @return $this
19
     */
20 4
    public function notSameAs($value)
21
    {
22 4
        $this->options['compared_value'] = $value;
23
24 4
        return $this;
25
    }
26
27
    /**
28
     * @inheritdoc
29
     */
30 3
    protected function compare()
31
    {
32 3
        $result = $this->value !== $this->options['compared_value'];
33
34 3
        if (!$result) {
35 2
            $this->setError(self::E_SAME);
36
        }
37
38 3
        return $result;
39
    }
40
}
41