Min   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 80%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 24
ccs 4
cts 5
cp 0.8
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A check() 0 12 2
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
use Dimtrovich\Validation\Traits\SizeTrait;
15
16
class Min extends AbstractRule
17
{
18
    use SizeTrait;
19
20
    /**
21
     * @var array
22
     */
23
    protected $fillableParams = ['min'];
24
25
    /**
26
     * {@inheritDoc}
27
     */
28
    public function check($value): bool
29
    {
30 2
        $this->requireParameters($this->fillableParams);
31
32 2
        $min       = $this->getBytesSize($this->parameter('min'));
33 2
        $valueSize = $this->getValueSize($value);
34
35
        if (! is_numeric($valueSize)) {
36
            return false;
37
        }
38
39 2
        return $valueSize >= $min;
40
    }
41
}
42