Completed
Push — master ( 1e5c1d...1e0ecd )
by Mikołaj
01:31 queued 11s
created

TaxonAwareTrait::getTaxons()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file has been created by developers from BitBag.
5
 * Feel free to contact us once you face any issues or want to start
6
 * another great project.
7
 * You can find more information about us on https://bitbag.shop and write us
8
 * an email on [email protected].
9
 */
10
11
declare(strict_types=1);
12
/*
13
 * This file has been created by developers from BitBag.
14
 * Feel free to contact us once you face any issues or want to start
15
 * another great project.
16
 * You can find more information about us on https://bitbag.shop and write us
17
 * an email on [email protected].
18
 */
19
20
namespace BitBag\SyliusCmsPlugin\Entity;
21
22
use Doctrine\Common\Collections\ArrayCollection;
23
use Doctrine\Common\Collections\Collection;
24
use Sylius\Component\Core\Model\TaxonInterface;
25
26
trait TaxonAwareTrait
27
{
28
    /** @var Collection|TaxonInterface[] */
29
    protected $taxonomies;
30
31
    public function initializeTaxonCollection(): void
32
    {
33
        $this->taxonomies = new ArrayCollection();
0 ignored issues
show
Documentation Bug introduced by
It seems like new \Doctrine\Common\Collections\ArrayCollection() of type object<Doctrine\Common\C...ctions\ArrayCollection> is incompatible with the declared type object<Doctrine\Common\C...\Model\TaxonInterface>> of property $taxonomies.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
34
    }
35
36
    public function getTaxons(): Collection
37
    {
38
        return $this->taxonomies;
39
    }
40
41
    public function hasTaxon(TaxonInterface $taxon): bool
42
    {
43
        return $this->taxonomies->contains($taxon);
44
    }
45
46
    public function addTaxon(TaxonInterface $taxon): void
47
    {
48
        if (false === $this->hasTaxon($taxon)) {
49
            $this->taxonomies->add($taxon);
50
        }
51
    }
52
53
    public function removeTaxon(TaxonInterface $taxon): void
54
    {
55
        if (true === $this->hasTaxon($taxon)) {
56
            $this->taxonomies->removeElement($taxon);
57
        }
58
    }
59
}
60