Confirm::process()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
cc 4
nc 3
nop 1
1
<?php
2
3
namespace Faulancer\Form\Validator\Base;
4
5
use Faulancer\Form\Validator\AbstractValidator;
6
7
/**
8
 * Class Confirm
9
 *
10
 * @package Faulancer\Form\Validator\Base
11
 * @author Florian Knapp <[email protected]>
12
 */
13
class Confirm extends AbstractValidator
14
{
15
16
    static private $initialInput = null;
17
18
    /**
19
     * The error message as key for translation
20
     * @var string
21
     */
22
    protected $errorMessage = 'validator_not_same';
23
24
    /**
25
     * Validate type string
26
     *
27
     * @param $data
28
     *
29
     * @return bool
30
     */
31
    public function process($data)
32
    {
33
        if (empty(self::$initialInput)) {
34
            self::$initialInput = $data;
35
            return true;
36
        } elseif (!empty(self::$initialInput) && self::$initialInput === $data) {
37
            return true;
38
        }
39
40
        self::$initialInput = null;
41
        return false;
42
    }
43
44
}