Passed
Pull Request — master (#248)
by Rustam
12:42
created

CompareTo::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 46
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2.1481

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 46
ccs 2
cts 3
cp 0.6667
rs 10
cc 2
nc 2
nop 8
crap 2.1481

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Validator\Rule;
6
7
use Attribute;
8
use Closure;
9
use InvalidArgumentException;
10
use JetBrains\PhpStorm\ArrayShape;
11
use RuntimeException;
12
use Yiisoft\Validator\ParametrizedRuleInterface;
13
use Yiisoft\Validator\BeforeValidationInterface;
14
use Yiisoft\Validator\Rule\Trait\HandlerClassNameTrait;
15
use Yiisoft\Validator\Rule\Trait\BeforeValidationTrait;
16
use Yiisoft\Validator\Rule\Trait\RuleNameTrait;
17
use Yiisoft\Validator\ValidationContext;
18
19
/**
20
 * Validates the specified value with another value or attribute.
21
 *
22
 * The value being compared with a constant {@see CompareTo::$compareValue}, which is set
23
 * in the constructor.
24
 *
25
 * It supports different comparison operators, specified
26
 * via the {@see CompareTo::$operator}.
27
 *
28
 * The default comparison function is based on string values, which means the values
29
 * are compared byte by byte. When comparing numbers, make sure to change {@see CompareTo::$type} to
30
 * {@see CompareTo::TYPE_NUMBER} to enable numeric comparison.
31
 */
32
#[Attribute(Attribute::TARGET_PROPERTY)]
33
final class CompareTo extends Compare
34
{
35 1
    public function getHandlerClassName(): string
36
    {
37 1
        return CompareHandler::class;
38
    }
39
}
40