<?php

declare(strict_types=1);

/*
 * This file is part of the Serenity package.
 *
 * (c) CP Creation <web@cpcreation.fr>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Serenity\CoreBundle\Shared\Feature;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Gedmo\Mapping\Annotation as Gedmo;

trait NestedTreeTrait
{
    #[Gedmo\TreeRoot]
    private ?NestedTreeInterface $root = null;

    #[Gedmo\TreeParent]
    private ?NestedTreeInterface $parent = null;

    /**
     * @var Collection<int, NestedTreeInterface>
     */
    private Collection $children;

    #[Gedmo\TreeLevel]
    private int $lvl = 0;

    #[Gedmo\TreeLeft]
    private int $lft = 0;

    #[Gedmo\TreeRight]
    private int $rgt = 0;

    public function __construct()
    {
        $this->children = new ArrayCollection();
    }

    public function getRoot(): ?NestedTreeInterface
    {
        return $this->root;
    }

    public function setRoot(?NestedTreeInterface $root): void
    {
        $this->root = $root;
    }

    public function getParent(): ?NestedTreeInterface
    {
        return $this->parent;
    }

    public function setParent(?NestedTreeInterface $parent): void
    {
        $this->parent = $parent;
    }

    /**
     * @return Collection<int, NestedTreeInterface>
     */
    public function getChildren(): Collection
    {
        return $this->children;
    }

    /**
     * @param Collection<int, NestedTreeInterface> $children
     */
    public function setChildren(Collection $children): void
    {
        $this->children = $children;
    }

    public function getLvl(): int
    {
        return $this->lvl;
    }

    public function setLvl(int $lvl): void
    {
        $this->lvl = $lvl;
    }

    public function getLft(): int
    {
        return $this->lft;
    }

    public function setLft(int $lft): void
    {
        $this->lft = $lft;
    }

    public function getRgt(): int
    {
        return $this->rgt;
    }

    public function setRgt(int $rgt): void
    {
        $this->rgt = $rgt;
    }
}
