StatefulEntityTrait::status()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
/*
3
 * This file is part of the PommProject/ModelManager package.
4
 *
5
 * (c) 2014 - 2015 Grégoire HUBERT <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace PommProject\ModelManager\Model\FlexibleEntity;
11
12
/**
13
 * StatefulEntityTrait
14
 *
15
 * Entities with the ability to keep record of their modification or
16
 * persistence status.
17
 *
18
 * @package     ModelManager
19
 * @copyright   2014 - 2015 Grégoire HUBERT
20
 * @author      Grégoire HUBERT
21
 * @license     X11 {@link http://opensource.org/licenses/mit-license.php}
22
 * @see         FlexibleEntityInterface
23
 */
24
trait StatefulEntityTrait
25
{
26
    private $status = FlexibleEntityInterface::STATUS_NONE;
27
28
    /**
29
     * @see FlexibleEntityInterface
30
     */
31
    public function status($status = null)
32
    {
33
        if ($status !== null) {
34
            $this->status = (int) $status;
35
36
            return $this;
37
        }
38
39
        return $this->status;
40
    }
41
42
    /**
43
     * touch
44
     *
45
     * Set the entity as modified.
46
     *
47
     * @access public
48
     * @return FlexibleEntityInterface
49
     */
50
    public function touch()
51
    {
52
        $this->status |= FlexibleEntityInterface::STATUS_MODIFIED;
53
54
        return $this;
55
    }
56
}
57