Completed
Push — master ( 224468...971710 )
by
unknown
08:12 queued 10s
created

VendorsTrait::getVendors()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 1
b 1
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Odiseo\SyliusVendorPlugin\Entity;
6
7
use Doctrine\Common\Collections\Collection;
8
9
trait VendorsTrait
10
{
11
    /** @var Collection|VendorInterface[] */
12
    protected $vendors;
13
14
    /**
15
     * @return Collection|VendorInterface[]
16
     */
17
    public function getVendors(): Collection
18
    {
19
        return $this->vendors;
20
    }
21
22
    /**
23
     * @param VendorInterface $vendor
24
     * @return bool
25
     */
26
    public function hasVendor(VendorInterface $vendor): bool
27
    {
28
        return $this->vendors->contains($vendor);
29
    }
30
31
    /**
32
     * @param VendorInterface $vendor
33
     */
34
    public function addVendor(VendorInterface $vendor): void
35
    {
36
        if (!$this->hasVendor($vendor)) {
37
            $this->vendors->add($vendor);
38
        }
39
    }
40
41
    /**
42
     * @param VendorInterface $vendor
43
     */
44
    public function removeVendor(VendorInterface $vendor): void
45
    {
46
        if ($this->hasVendor($vendor)) {
47
            $this->vendors->removeElement($vendor);
48
        }
49
    }
50
}
51