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

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