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

SpecialValue   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
dl 0
loc 25
rs 10
c 1
b 0
f 0
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A isEmpty() 0 3 3
A notSet() 0 3 1
A isNotSet() 0 3 1
A init() 0 3 1
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