Completed
Pull Request — 2.0 (#71)
by Mikael
01:35
created

ModifiedColumnEntityTrait::getModifiedColumns()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
rs 10
c 1
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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
     * AddModifiedColumn
35
     *
36
     * @param $column
37
     * @return FlexibleEntityInterface
38
     */
39
    public function addModifiedColumn($column)
40
    {
41
        if (!in_array($column, $this->modified_columns))
42
            $this->modified_columns[] = $column;
43
44
        return $this;
45
    }
46
47
    /**
48
     * removeModifiedColumn
49
     *
50
     * @param $column
51
     * @return FlexibleEntityInterface
52
     */
53
    public function removeModifiedColumn($column)
54
    {
55
        if (($key = array_search($column, $this->modified_columns, true)) !== FALSE)
56
            unset($this->modified_columns[$key]);
57
58
        return $this;
59
    }
60
}