StatefulEntityTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 1
cbo 0
dl 0
loc 33
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A status() 0 10 2
A touch() 0 6 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