ValueState::set()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 1
b 0
f 0
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