ValueState   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
dl 0
loc 29
ccs 12
cts 12
cp 1
rs 10
c 1
b 0
f 0
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A clear() 0 3 1
A isChanged() 0 3 1
A get() 0 6 2
A __construct() 0 2 1
A set() 0 3 1
1
<?php
2
/**
3
 * This file is part of the eav package.
4
 * @author    Alex Kuperwood <[email protected]>
5
 * @copyright 2025 Alex Kuperwood
6
 * @license   https://opensource.org/license/mit  The MIT License
7
 */
8
declare(strict_types=1);
9
10
namespace Kuperwood\Eav\Value;
11
12
/**
13
 * @property $data
14
 */
15
class ValueState
16
{
17
    protected $value;
18
19 1
    public function __construct() {
20 1
        $this->clear();
21
    }
22
23 2
    public function set($value) : void
24
    {
25 2
        $this->value = $value;
26
    }
27
28 1
    public function get()
29
    {
30 1
        if(!$this->isChanged())
31 1
            return null;
32
33 1
        return $this->value;
34
    }
35
36 1
    public function isChanged() : bool
37
    {
38 1
        return !$this->value instanceof ValueEmpty;
39
    }
40
41 1
    public function clear() : void
42
    {
43 1
        $this->value = new ValueEmpty();
44
    }
45
}
46