Code Duplication    Length = 18-18 lines in 2 locations

Entity/Category.php 1 location

@@ 183-200 (lines=18) @@
180
     *
181
     * @return Category
182
     */
183
    public function setParent(Category $parent = null): Category
184
    {
185
        if ($parent === $this) {
186
            // Refuse the category to have itself as parent.
187
            $this->parent = null;
188
189
            return $this;
190
        }
191
192
        $this->parent = $parent;
193
194
        // Ensure bidirectional relation is respected.
195
        if ($parent && false === $parent->getChildren()->indexOf($this)) {
196
            $parent->addChild($this);
197
        }
198
199
        return $this;
200
    }
201
202
    /**
203
     * @return \DateTime

Entity/Page.php 1 location

@@ 358-375 (lines=18) @@
355
     *
356
     * @return Page
357
     */
358
    public function setParent(Page $parent = null): Page
359
    {
360
        if ($parent === $this) {
361
            // Refuse the category to have itself as parent.
362
            $this->parent = null;
363
364
            return $this;
365
        }
366
367
        $this->parent = $parent;
368
369
        // Ensure bidirectional relation is respected.
370
        if ($parent && false === $parent->getChildren()->indexOf($this)) {
371
            $parent->addChild($this);
372
        }
373
374
        return $this;
375
    }
376
377
378
    /**