SectionableTrait::removeSection()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 2
nc 2
nop 1
1
<?php
2
3
/*
4
 * This file was created by developers working at BitBag
5
 * Do you need more information about us and what we do? Visit our https://bitbag.io website!
6
 * We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career
7
*/
8
9
declare(strict_types=1);
10
11
namespace BitBag\SyliusCmsPlugin\Entity;
12
13
use Doctrine\Common\Collections\ArrayCollection;
14
use Doctrine\Common\Collections\Collection;
15
16
trait SectionableTrait
17
{
18
    /** @var Collection|SectionInterface[] */
19
    protected $sections;
20
21
    public function initializeSectionsCollection(): void
22
    {
23
        $this->sections = new ArrayCollection();
24
    }
25
26
    public function getSections(): ?Collection
27
    {
28
        return $this->sections;
29
    }
30
31
    public function hasSection(SectionInterface $section): bool
32
    {
33
        return $this->sections->contains($section);
34
    }
35
36
    public function addSection(SectionInterface $section): void
37
    {
38
        if (false === $this->hasSection($section)) {
39
            $this->sections->add($section);
40
        }
41
    }
42
43
    public function removeSection(SectionInterface $section): void
44
    {
45
        if (true === $this->hasSection($section)) {
46
            $this->sections->removeElement($section);
47
        }
48
    }
49
}
50