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

NotSame::notSameAs()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
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