Completed
Branch feature/pre-split (a35c5b)
by Anton
03:21
created

SolidStateTrait::isSolid()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * components
4
 *
5
 * @author    Wolfy-J
6
 */
7
namespace Spiral\Models\Traits;
8
9
/**
10
 * Provides ability for object (entity or accessor) to indicate that it's values must always be
11
 * stored together (no dirty fields, no atomic operations).
12
 *
13
 * Note: it's not the same as solid state relay :)
14
 */
15
trait SolidStateTrait
16
{
17
    /**
18
     * SolidState MUST force object to be saved as one big dataset without any atomic operations
19
     * or dirty field processing.
20
     *
21
     * @var bool
22
     */
23
    private $solidState = false;
24
25
    /**
26
     * Declare object as solid.
27
     *
28
     * @param bool $solidState
29
     *
30
     * @return $this
31
     */
32
    public function solidState(bool $solidState = true)
33
    {
34
        $this->solidState = $solidState;
35
36
        return $this;
37
    }
38
39
    /**
40
     * Is object is solid state?
41
     *
42
     * @see solidState()
43
     *
44
     * @return bool
45
     */
46
    public function isSolid()
47
    {
48
        return $this->solidState;
49
    }
50
}