1 | <?php |
||
10 | class Index { |
||
11 | |||
12 | /** |
||
13 | * @var string |
||
14 | */ |
||
15 | private $keyName; |
||
16 | |||
17 | /** |
||
18 | * @var bool |
||
19 | */ |
||
20 | private $unique; |
||
21 | |||
22 | /** |
||
23 | * @var string[] |
||
24 | */ |
||
25 | private $columns; |
||
26 | |||
27 | /** |
||
28 | * @param string $keyName Index key name |
||
29 | * @param bool $unique Index unique |
||
30 | * @param string[] $columns Index column names |
||
31 | */ |
||
32 | public function __construct($keyName, $unique, $columns) { |
||
33 | $this->keyName = $keyName; |
||
34 | $this->unique = $unique; |
||
35 | $this->columns = $columns; |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * Get Index key name |
||
40 | * |
||
41 | * @return string Index key name |
||
42 | */ |
||
43 | 1 | public function getKeyName() { |
|
46 | |||
47 | /** |
||
48 | * Is Index primary key |
||
49 | * |
||
50 | * @return bool TRUE if primary key, otherwise FALSE |
||
51 | */ |
||
52 | 2 | public function isPrimaryKey() { |
|
53 | 2 | $isPrimaryKey = $this->getKeyName() === 'PRIMARY'; |
|
54 | |||
55 | 2 | return $isPrimaryKey; |
|
56 | } |
||
57 | |||
58 | /** |
||
59 | * Is Index unique |
||
60 | * |
||
61 | * @return bool TRUE if unique, otherwise FALSE |
||
62 | */ |
||
63 | 2 | public function isUnique() { |
|
66 | |||
67 | /** |
||
68 | * Get Index column names |
||
69 | * |
||
70 | * @return string[] Index column names |
||
71 | */ |
||
72 | 1 | public function getColumns() { |
|
75 | |||
76 | /** |
||
77 | * Check if given Index is duplicate of this |
||
78 | * |
||
79 | * @param Index $index Index |
||
80 | * |
||
81 | * @return bool TRUE if duplicate, otherwise FALSE |
||
82 | */ |
||
83 | 5 | public function isDuplicate(Index $index) { |
|
105 | |||
106 | /** |
||
107 | * Check if given columns are equal to this index columns |
||
108 | * |
||
109 | * @param string[] $columns |
||
110 | * |
||
111 | * @return bool TRUE if equal, otherwise FALSE |
||
112 | */ |
||
113 | 4 | public function isColumnsEqual($columns) { |
|
118 | } |
||
119 |