Completed
Push — 2.x ( 0b6590...78009d )
by Aleksei
20s queued 15s
created

SpecialValue::isEmpty()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 1
nc 3
nop 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cycle\ORM\Relation;
6
7
/**
8
 * @internal
9
 */
10
final class SpecialValue
11
{
12
    private static self $empty;
13
14
    public static function init(): void
15
    {
16
        self::$empty = new self();
17
    }
18
19
    /**
20
     * An empty value that is used to indicate that a value has not been set.
21
     */
22
    public static function notSet(): self
23
    {
24
        return self::$empty;
25
    }
26
27
    public static function isNotSet(mixed $value): bool
28
    {
29
        return $value === self::$empty;
30
    }
31
32
    public static function isEmpty(mixed $value): bool
33
    {
34
        return $value === self::$empty || $value === null || $value === [];
35
    }
36
}
37
38
SpecialValue::init();
39