Completed
Pull Request — master (#1339)
by José
01:55
created

AlterTable::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
/**
3
 * Phinx
4
 *
5
 * (The MIT license)
6
 *
7
 * Permission is hereby granted, free of charge, to any person obtaining a copy
8
 * of this software and associated * documentation files (the "Software"), to
9
 * deal in the Software without restriction, including without limitation the
10
 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
11
 * sell copies of the Software, and to permit persons to whom the Software is
12
 * furnished to do so, subject to the following conditions:
13
 *
14
 * The above copyright notice and this permission notice shall be included in
15
 * all copies or substantial portions of the Software.
16
 *
17
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
23
 * IN THE SOFTWARE.
24
 */
25
namespace Phinx\Db\Plan;
26
27
use Phinx\Db\Action\Action;
28
use Phinx\Db\Table\Table;
29
30
/**
31
 * A collection of ALTER actions for a single table
32
 *
33
 */
34
class AlterTable
35
{
36
    /**
37
     * The table
38
     *
39
     * @var \Phinx\Db\Table\Table
40
     */
41
    protected $table;
42
43
    /**
44
     * The listo of actions to execute
45
     *
46
     * @var \Phinx\Db\Action\Action[]
47
     */
48
    protected $actions = [];
49
50
    /**
51
     * Constructor
52
     *
53
     * @param Table $table The table to change
54
     */
55
    public function __construct(Table $table)
56
    {
57
        $this->table = $table;
58
    }
59
60
    /**
61
     * Adds another action to the collection
62
     *
63
     * @param Action $action The action to add
64
     * @return void
65
     */
66
    public function addAction(Action $action)
67
    {
68
        $this->actions[] = $action;
69
    }
70
71
    /**
72
     * Returns the table associated to this collection
73
     *
74
     * @return Table
75
     */
76
    public function getTable()
77
    {
78
        return $this->table;
79
    }
80
81
    /**
82
     * Returns an array with all collected actions
83
     *
84
     * @return Action[]
85
     */
86
    public function getActions()
87
    {
88
        return $this->actions;
89
    }
90
}
91