FieldsChecker::equalsTo()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
namespace Vvval\Spiral\Validation\Checkers;
4
5
use Spiral\Validation\Prototypes\AbstractChecker;
6
7
class FieldsChecker extends AbstractChecker
8
{
9
    /**
10
     * Default error messages associated with checker method by name.
11
     * {@inheritdoc}
12
     */
13
    const MESSAGES = [
14
        'equalsTo' => '[[Values should match.]]',
15
    ];
16
17
    /**
18
     * Checks equality between given value and another field's value.
19
     *
20
     * @param string $value
21
     * @param string $field
22
     *
23
     * @return bool
24
     */
25
    public function equalsTo(string $value, string $field): bool
26
    {
27
        return $value === $this->getValidator()->getValue($field);
28
    }
29
}