Passed
Pull Request — master (#519)
by
unknown
03:06
created

Compare::getOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 27
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 20
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 27
ccs 0
cts 0
cp 0
crap 2
rs 9.6
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Validator\Rule;
6
7
use Attribute;
8
9
/**
10
 * Defines validation options to check that the specified value matches with another value or attribute.
11
 *
12
 * The value being compared with a constant {@see Compare::$targetValue}, which is set
13
 * in the constructor.
14
 *
15
 * It supports different comparison operators, specified via the {@see Compare::$operator}.
16
 *
17
 * There are shortcut classes to use instead of specifying operator manually:
18
 *
19
 * - {@see Equal} is a shortcut for `new Compare(operator: '==')` and `new Compare(operator: '===')`.
20
 * - {@see NotEqual} is a shortcut for `new Compare(operator: '!=')` and `new Compare(operator: '!==')`.
21
 * - {@see GreaterThan} is a shortcut for `new Compare(operator: '>')`.
22
 * - {@see GreaterThanOrEqual} is a shortcut for `new Compare(operator: '>=')`.
23
 * - {@see LessThan} is a shortcut for `new Compare(operator: '<')`.
24
 * - {@see LessThanOrEqual} is a shortcut for `new Compare(operator: '<=')`.
25
 *
26
 * The default comparison function is based on string values, which means the values
27
 * are compared byte by byte. When comparing numbers, make sure to change {@see Compare::$type} to
28
 * {@see Compare::TYPE_NUMBER} to enable numeric comparison.
29
 *
30
 * @see CompareHandler
31
 */
32
#[Attribute(Attribute::TARGET_PROPERTY | Attribute::IS_REPEATABLE)]
33
final class Compare extends AbstractCompare
34
{
35
    public function getName(): string
36
    {
37
        return 'compare';
38
    }
39
}
40