Test Failed
Pull Request — master (#19)
by Flo
04:22
created

Confirm   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 31
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 12 4
1
<?php
2
/**
3
 * Class Confirm | Confirm.php
4
 * @package Faulancer\Form\Validator\Base
5
 * @author Florian Knapp <[email protected]>
6
 */
7
namespace Faulancer\Form\Validator\Base;
8
9
use Faulancer\Form\Validator\AbstractValidator;
10
11
/**
12
 * Class Text
13
 */
14
class Confirm extends AbstractValidator
15
{
16
17
    static private $initialInput = null;
18
19
    /**
20
     * The error message as key for translation
21
     * @var string
22
     */
23
    protected $errorMessage = 'validator_not_same';
24
25
    /**
26
     * Validate type string
27
     * @param $data
28
     * @return boolean
29
     * @codeCoverageIgnore
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
}