Passed
Pull Request — master (#248)
by Rustam
02:27
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
9
/**
10
 * Validates the specified value with another value or attribute.
11
 *
12
 * The value being compared with a constant {@see CompareTo::$compareValue}, which is set
13
 * in the constructor.
14
 *
15
 * It supports different comparison operators, specified
16
 * via the {@see CompareTo::$operator}.
17
 *
18
 * The default comparison function is based on string values, which means the values
19
 * are compared byte by byte. When comparing numbers, make sure to change {@see CompareTo::$type} to
20
 * {@see CompareTo::TYPE_NUMBER} to enable numeric comparison.
21
 */
22
#[Attribute(Attribute::TARGET_PROPERTY | Attribute::IS_REPEATABLE)]
23
final class CompareTo extends Compare
24
{
25 2
    public function getHandlerClassName(): string
26
    {
27 2
        return CompareHandler::class;
28
    }
29
}
30