Code Duplication    Length = 29-29 lines in 2 locations

src/SQLParser/Node/Table.php 1 location

@@ 221-249 (lines=29) @@
218
     *
219
     * @param VisitorInterface $visitor
220
     */
221
    public function walk(VisitorInterface $visitor)
222
    {
223
        $node = $this;
224
        $result = $visitor->enterNode($node);
225
        if ($result instanceof NodeInterface) {
226
            $node = $result;
227
        }
228
        if ($result !== NodeTraverser::DONT_TRAVERSE_CHILDREN) {
229
            if (is_array($this->refClause)) {
230
                foreach ($this->refClause as $key => $operand) {
231
                    $result2 = $operand->walk($visitor);
232
                    if ($result2 === NodeTraverser::REMOVE_NODE) {
233
                        unset($this->refClause[$key]);
234
                    } elseif ($result2 instanceof NodeInterface) {
235
                        $this->refClause[$key] = $result2;
236
                    }
237
                }
238
            } elseif ($this->refClause) {
239
                $result2 = $this->refClause->walk($visitor);
240
                if ($result2 === NodeTraverser::REMOVE_NODE) {
241
                    $this->refClause = null;
242
                } elseif ($result2 instanceof NodeInterface) {
243
                    $this->refClause = $result2;
244
                }
245
            }
246
        }
247
248
        return $visitor->leaveNode($node);
249
    }
250
}
251

src/SQLParser/Node/Expression.php 1 location

@@ 231-259 (lines=29) @@
228
     *
229
     * @param VisitorInterface $visitor
230
     */
231
    public function walk(VisitorInterface $visitor)
232
    {
233
        $node = $this;
234
        $result = $visitor->enterNode($node);
235
        if ($result instanceof NodeInterface) {
236
            $node = $result;
237
        }
238
        if ($result !== NodeTraverser::DONT_TRAVERSE_CHILDREN) {
239
            if (is_array($this->subTree)) {
240
                foreach ($this->subTree as $key => $operand) {
241
                    $result2 = $operand->walk($visitor);
242
                    if ($result2 === NodeTraverser::REMOVE_NODE) {
243
                        unset($this->subTree[$key]);
244
                    } elseif ($result2 instanceof NodeInterface) {
245
                        $this->subTree[$key] = $result2;
246
                    }
247
                }
248
            } else {
249
                $result2 = $this->subTree->walk($visitor);
250
                if ($result2 === NodeTraverser::REMOVE_NODE) {
251
                    $this->subTree = [];
252
                } elseif ($result2 instanceof NodeInterface) {
253
                    $this->subTree = $result2;
254
                }
255
            }
256
        }
257
258
        return $visitor->leaveNode($node);
259
    }
260
}
261