Gt   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 27
ccs 5
cts 5
cp 1
rs 10
wmc 7

1 Method

Rating   Name   Duplication   Size   Complexity  
B check() 0 17 7
1
<?php
2
3
/**
4
 * This file is part of Dimtrovich/Validation.
5
 *
6
 * (c) 2023 Dimitri Sitchet Tomkeu <[email protected]>
7
 *
8
 * For the full copyright and license information, please view
9
 * the LICENSE file that was distributed with this source code.
10
 */
11
12
namespace Dimtrovich\Validation\Rules;
13
14
class Gt extends AbstractRule
15
{
16
    /**
17
     * @var array
18
     */
19
    protected $fillableParams = ['value'];
20
21
    /**
22
     * {@inheritDoc}
23
     */
24
    public function check($value): bool
25
    {
26 2
        $this->requireParameters($this->fillableParams);
27
28
        if (is_int($value) || is_float($value)) {
29 2
            $value = (string) $value;
30
        }
31
32
        if (! is_string($value)) {
33 2
            return false;
34
        }
35
36
        if (! is_numeric($compare = $this->parameter('value'))) {
37 2
            $compare = $this->getAttribute()->getValue($compare);
38
        }
39
40 2
        return is_numeric($value) && is_numeric($compare) && $value > $compare;
41
    }
42
}
43