1 | <?php |
||
5 | class NameParser |
||
6 | { |
||
7 | /** |
||
8 | * The migration name. |
||
9 | * |
||
10 | * @var string |
||
11 | */ |
||
12 | protected $name; |
||
13 | |||
14 | /** |
||
15 | * The array data. |
||
16 | * |
||
17 | * @var array |
||
18 | */ |
||
19 | protected $data = []; |
||
20 | |||
21 | /** |
||
22 | * The available schema actions. |
||
23 | * |
||
24 | * @var array |
||
25 | */ |
||
26 | protected $actions = [ |
||
27 | 'create' => [ |
||
28 | 'create', |
||
29 | 'make', |
||
30 | ], |
||
31 | 'delete' => [ |
||
32 | 'delete', |
||
33 | 'remove', |
||
34 | ], |
||
35 | 'add' => [ |
||
36 | 'add', |
||
37 | 'update', |
||
38 | 'append', |
||
39 | 'insert', |
||
40 | ], |
||
41 | 'drop' => [ |
||
42 | 'destroy', |
||
43 | 'drop', |
||
44 | ], |
||
45 | ]; |
||
46 | |||
47 | /** |
||
48 | * The constructor. |
||
49 | * |
||
50 | * @param string $name |
||
51 | */ |
||
52 | 2 | public function __construct($name) |
|
57 | |||
58 | /** |
||
59 | * Get original migration name. |
||
60 | * |
||
61 | * @return string |
||
62 | */ |
||
63 | public function getOriginalName() |
||
67 | |||
68 | /** |
||
69 | * Get schema type or action. |
||
70 | * |
||
71 | * @return string |
||
72 | */ |
||
73 | 2 | public function getAction() |
|
77 | |||
78 | /** |
||
79 | * Get table name. |
||
80 | * |
||
81 | * @return string |
||
82 | */ |
||
83 | 2 | public function getTable() |
|
87 | |||
88 | /** |
||
89 | * Get the table will be used. |
||
90 | * |
||
91 | * @return string |
||
92 | */ |
||
93 | 2 | public function getTableName() |
|
99 | |||
100 | /** |
||
101 | * Get matches data from regex. |
||
102 | * |
||
103 | * @return array |
||
104 | */ |
||
105 | 2 | public function getMatches() |
|
111 | |||
112 | /** |
||
113 | * Get name pattern. |
||
114 | * |
||
115 | * @return string |
||
116 | */ |
||
117 | 2 | public function getPattern() |
|
138 | |||
139 | /** |
||
140 | * Fetch the migration name to an array data. |
||
141 | * |
||
142 | * @return array |
||
143 | */ |
||
144 | 2 | protected function fetchData() |
|
148 | |||
149 | /** |
||
150 | * Get the array data. |
||
151 | * |
||
152 | * @return array |
||
153 | */ |
||
154 | public function getData() |
||
158 | |||
159 | /** |
||
160 | * Determine whether the given type is same with the current schema action or type. |
||
161 | * |
||
162 | * @param $type |
||
163 | * |
||
164 | * @return bool |
||
165 | */ |
||
166 | public function is($type) |
||
170 | |||
171 | /** |
||
172 | * Determine whether the current schema action is a adding action. |
||
173 | * |
||
174 | * @return bool |
||
175 | */ |
||
176 | public function isAdd() |
||
180 | |||
181 | /** |
||
182 | * Determine whether the current schema action is a deleting action. |
||
183 | * |
||
184 | * @return bool |
||
185 | */ |
||
186 | public function isDelete() |
||
190 | |||
191 | /** |
||
192 | * Determine whether the current schema action is a creating action. |
||
193 | * |
||
194 | * @return bool |
||
195 | */ |
||
196 | 2 | public function isCreate() |
|
200 | |||
201 | /** |
||
202 | * Determine whether the current schema action is a dropping action. |
||
203 | * |
||
204 | * @return bool |
||
205 | */ |
||
206 | public function isDrop() |
||
210 | } |
||
211 |
The break statement is not necessary if it is preceded for example by a return statement:
If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.