Completed
Pull Request — master (#71)
by Mikael
01:45
created

ModifiedColumnEntityTrait::addModifiedColumn()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
/*
3
 * This file is part of the PommProject/ModelManager package.
4
 *
5
 * (c) 2014 - 2016 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
 * ModifiedColumnEntityTrait
14
 *
15
 * @package     ModelManager
16
 * @copyright   2014 - 2015 Grégoire HUBERT
17
 * @author      Mikael Paris
18
 * @license     X11 {@link http://opensource.org/licenses/mit-license.php}
19
 * @see         FlexibleEntityInterface
20
 */
21
trait ModifiedColumnEntityTrait
22
{
23
    private $modified_columns = [];
24
25
    /**
26
     * @return array
27
     */
28
    public function getModifiedColumns()
29
    {
30
        return $this->modified_columns;
31
    }
32
33
    /**
34
     * @param $column
35
     * @return FlexibleEntityInterface
36
     */
37
    public function addModifiedColumn($column)
38
    {
39
        if (!in_array($column, $this->modified_columns)) {
40
            $this->modified_columns[] = $column;
41
        }
42
43
        return $this;
44
    }
45
46
    /**
47
     * @param $column
48
     * @return FlexibleEntityInterface
49
     */
50
    public function removeModifiedColumn($column)
51
    {
52
        $key = array_search($column, $this->modified_columns, true);
53
54
        if ($key !== FALSE) {
55
            unset($this->modified_columns[$key]);
56
        }
57
58
        return $this;
59
    }
60
}
61