Passed
Push — master ( cbbc27...86f200 )
by Dev
11:12
created

PageRelatedPagesTrait::__constructRelatedPagesT()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace PiedWeb\CMSBundle\Entity;
4
5
use Doctrine\Common\Collections\Collection;
6
use Doctrine\ORM\Mapping as ORM;
7
8
trait PageRelatedPagesTrait
9
{
10
    /**
11
     * @ORM\ManyToMany(targetEntity="PiedWeb\CMSBundle\Entity\PageInterface")
12
     */
13
    protected $relatedPages;
14
15
    public function __constructRelatedPagesT()
16
    {
17
        $this->relatedPages = new ArrayCollection();
0 ignored issues
show
Bug introduced by
The type PiedWeb\CMSBundle\Entity\ArrayCollection was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
18
    }
19
20
    /**
21
     * @return Collection|Page[]
22
     */
23
    public function getRelatedPages(): Collection
24
    {
25
        return $this->relatedPages;
26
    }
27
28
    public function addRelatedPage(PageInterface $relatedPage): self
29
    {
30
        if (!$this->relatedPages->contains($relatedPage)) {
31
            $this->relatedPages[] = $relatedPage;
32
        }
33
34
        return $this;
35
    }
36
37
    public function removeRelatedPage(PageInterface $relatedPage): self
38
    {
39
        if ($this->relatedPages->contains($relatedPage)) {
40
            $this->relatedPages->removeElement($relatedPage);
41
        }
42
43
        return $this;
44
    }
45
}
46