Code Duplication    Length = 29-29 lines in 2 locations

src/SQLParser/Node/Expression.php 1 location

@@ 203-231 (lines=29) @@
200
     *
201
     * @param VisitorInterface $visitor
202
     */
203
    public function walk(VisitorInterface $visitor)
204
    {
205
        $node = $this;
206
        $result = $visitor->enterNode($node);
207
        if ($result instanceof NodeInterface) {
208
            $node = $result;
209
        }
210
        if ($result !== NodeTraverser::DONT_TRAVERSE_CHILDREN) {
211
            if (is_array($this->subTree)) {
212
                foreach ($this->subTree as $key => $operand) {
213
                    $result2 = $operand->walk($visitor);
214
                    if ($result2 === NodeTraverser::REMOVE_NODE) {
215
                        unset($this->subTree[$key]);
216
                    } elseif ($result2 instanceof NodeInterface) {
217
                        $this->subTree[$key] = $result2;
218
                    }
219
                }
220
            } else {
221
                $result2 = $this->subTree->walk($visitor);
222
                if ($result2 === NodeTraverser::REMOVE_NODE) {
223
                    $this->subTree = [];
224
                } elseif ($result2 instanceof NodeInterface) {
225
                    $this->subTree = $result2;
226
                }
227
            }
228
        }
229
230
        return $visitor->leaveNode($node);
231
    }
232
}
233

src/SQLParser/Node/Table.php 1 location

@@ 195-223 (lines=29) @@
192
     *
193
     * @param VisitorInterface $visitor
194
     */
195
    public function walk(VisitorInterface $visitor)
196
    {
197
        $node = $this;
198
        $result = $visitor->enterNode($node);
199
        if ($result instanceof NodeInterface) {
200
            $node = $result;
201
        }
202
        if ($result !== NodeTraverser::DONT_TRAVERSE_CHILDREN) {
203
            if (is_array($this->refClause)) {
204
                foreach ($this->refClause as $key => $operand) {
205
                    $result2 = $operand->walk($visitor);
206
                    if ($result2 === NodeTraverser::REMOVE_NODE) {
207
                        unset($this->refClause[$key]);
208
                    } elseif ($result2 instanceof NodeInterface) {
209
                        $this->refClause[$key] = $result2;
210
                    }
211
                }
212
            } elseif ($this->refClause) {
213
                $result2 = $this->refClause->walk($visitor);
214
                if ($result2 === NodeTraverser::REMOVE_NODE) {
215
                    $this->refClause = null;
216
                } elseif ($result2 instanceof NodeInterface) {
217
                    $this->refClause = $result2;
218
                }
219
            }
220
        }
221
222
        return $visitor->leaveNode($node);
223
    }
224
}
225