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

ModifiedColumnEntityTrait   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

3 Methods

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