Completed
Pull Request — master (#430)
by Anton
12:17
created

EqualsStrictRule::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Bluz Framework Component
4
 *
5
 * @copyright Bluz PHP Team
6
 * @link      https://github.com/bluzphp/framework
7
 */
8
9
declare(strict_types=1);
10
11
namespace Bluz\Validator\Rule;
12
13
/**
14
 * Check input data by compare with some value
15
 *
16
 * @package Bluz\Validator\Rule
17
 */
18
class EqualsStrictRule extends AbstractRule
19
{
20
    /**
21
     * @var string string for compare
22
     */
23
    protected $compareTo;
24
25
    /**
26
     * Setup validation rule
27
     *
28
     * @param string $compareTo
29
     */
30
    public function __construct($compareTo)
31
    {
32
        $this->compareTo = $compareTo;
33
    }
34
35
    /**
36
     * Check input data
37
     *
38
     * @param  string $input
39
     *
40
     * @return bool
41
     */
42
    public function validate($input): bool
43
    {
44
        return $input === $this->compareTo;
45
    }
46
47
    /**
48
     * Get error template
49
     *
50
     * @return string
51
     */
52
    public function getDescription() : string
53
    {
54
        return __('must be identical as "%s"', $this->compareTo);
55
    }
56
}
57