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

Table::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 2
1
<?php
2
namespace Phinx\Db\Table;
3
4
use InvalidArgumentException;
5
6
class Table
7
{
8
    /**
9
     * @var string
10
     */
11
    protected $name;
12
13
    /**
14
     * @var array
15
     */
16
    protected $options;
17
18
    /**
19
     * @param string $name The table name
20
     * @param array $options The creation options for this table
21
     */
22
    public function __construct($name, array $options = [])
23
    {
24
        if (empty($name)) {
25
            throw new InvalidArgumentException('Cannot use an empty table name');
26
        }
27
28
        $this->name = $name;
29
        $this->options = $options;
30
    }
31
32
    /**
33
     * Sets the table name.
34
     *
35
     * @param string $name The name of the table
36
     * @return \Phinx\Db\Table\Table
37
     */
38
    public function setName($name)
39
    {
40
        $this->name = $name;
41
42
        return $this;
43
    }
44
45
    /**
46
     * Gets the table name.
47
     *
48
     * @return string
49
     */
50
    public function getName()
51
    {
52
        return $this->name;
53
    }
54
55
    /**
56
     * Gets the table options
57
     *
58
     * @return array
59
     */
60
    public function getOptions()
61
    {
62
        return $this->options;
63
    }
64
65
    /**
66
     * Sets the table options
67
     *
68
     * @param array $options The options for the table creation
69
     * @return void
70
     */
71
    public function setOptions(array $options)
72
    {
73
        $this->options = $options;
74
    }
75
}
76