Code Duplication    Length = 29-30 lines in 2 locations

src/Statements/InsertStatement.php 1 location

@@ 211-239 (lines=29) @@
208
209
                $state = 1;
210
            } elseif ($state === 1) {
211
                if ($token->type === Token::TYPE_KEYWORD) {
212
                    if ($token->value === 'VALUE'
213
                        || $token->value === 'VALUES'
214
                    ) {
215
                        ++$list->idx; // skip VALUES
216
217
                        $this->values = Array2d::parse($parser, $list);
218
                    } elseif ($token->value === 'SET') {
219
                        ++$list->idx; // skip SET
220
221
                        $this->set = SetOperation::parse($parser, $list);
222
                    } elseif ($token->value === 'SELECT') {
223
                        $this->select = new SelectStatement($parser, $list);
224
                    } else {
225
                        $parser->error(
226
                            __('Unexpected keyword.'),
227
                            $token
228
                        );
229
                        break;
230
                    }
231
                    $state = 2;
232
                    $miniState = 1;
233
                } else {
234
                    $parser->error(
235
                        __('Unexpected token.'),
236
                        $token
237
                    );
238
                    break;
239
                }
240
            } elseif ($state == 2) {
241
                $lastCount = $miniState;
242

src/Statements/ReplaceStatement.php 1 location

@@ 174-203 (lines=30) @@
171
                }
172
173
                $state = 1;
174
            } elseif ($state === 1) {
175
                if ($token->type === Token::TYPE_KEYWORD) {
176
                    if ($token->value === 'VALUE'
177
                        || $token->value === 'VALUES'
178
                    ) {
179
                        ++$list->idx; // skip VALUES
180
181
                        $this->values = Array2d::parse($parser, $list);
182
                    } elseif ($token->value === 'SET') {
183
                        ++$list->idx; // skip SET
184
185
                        $this->set = SetOperation::parse($parser, $list);
186
                    } elseif ($token->value === 'SELECT') {
187
                        $this->select = new SelectStatement($parser, $list);
188
                    } else {
189
                        $parser->error(
190
                            __('Unexpected keyword.'),
191
                            $token
192
                        );
193
                        break;
194
                    }
195
                    $state = 2;
196
                } else {
197
                    $parser->error(
198
                        __('Unexpected token.'),
199
                        $token
200
                    );
201
                    break;
202
                }
203
            }
204
        }
205
206
        --$list->idx;