Passed
Pull Request — master (#245)
by Rustam
12:07
created

EmptyCheckTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 2
c 1
b 0
f 0
dl 0
loc 14
ccs 2
cts 2
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A isEmpty() 0 3 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Validator\Rule\Trait;
6
7
trait EmptyCheckTrait
8
{
9
    /**
10
     * Checks if the given value is empty.
11
     * A value is considered empty if it is null, an empty array, or an empty string.
12
     * Note that this method is different from PHP empty(). It will return false when the value is 0.
13
     *
14
     * @param mixed $value the value to be checked
15
     *
16
     * @return bool whether the value is empty
17
     */
18 28
    private function isEmpty(mixed $value): bool
19
    {
20 28
        return $value === null || $value === [] || $value === '';
21
    }
22
}
23