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

ModifiedColumnEntityTrait   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 40
rs 10
c 1
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getModifiedColumns() 0 4 1
A addModifiedColumn() 0 7 2
A removeModifiedColumn() 0 7 2
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
}