Completed
Push — master ( 7c1165...cb0569 )
by Dev
13:37
created

PageRelatedPagesTrait::removeRelatedPage()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 7
rs 10
c 1
b 1
f 0
1
<?php
2
3
namespace PiedWeb\CMSBundle\Entity;
4
5
use Doctrine\Common\Collections\ArrayCollection;
6
use Doctrine\Common\Collections\Collection;
7
use Doctrine\ORM\Mapping as ORM;
8
use Gedmo\Mapping\Annotation as Gedmo;
9
10
trait PageRelatedPagesTrait
11
{
12
    /**
13
     * @ORM\ManyToMany(targetEntity="PiedWeb\CMSBundle\Entity\PageInterface")
14
     */
15
    protected $relatedPages;
16
17
    /**
18
     * @return Collection|Page[]
19
     */
20
    public function getRelatedPages(): Collection
21
    {
22
        return $this->relatedPages;
23
    }
24
25
    public function addRelatedPage(PageInterface $relatedPage): self
26
    {
27
        if (!$this->relatedPages->contains($relatedPage)) {
28
            $this->relatedPages[] = $relatedPage;
29
        }
30
31
        return $this;
32
    }
33
34
    public function removeRelatedPage(PageInterface $relatedPage): self
35
    {
36
        if ($this->relatedPages->contains($relatedPage)) {
37
            $this->relatedPages->removeElement($relatedPage);
38
        }
39
40
        return $this;
41
    }
42
43
}
44