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

VendorsTrait   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 8
dl 0
loc 39
rs 10
c 1
b 1
f 0
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A hasVendor() 0 3 1
A addVendor() 0 4 2
A getVendors() 0 3 1
A removeVendor() 0 4 2
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