Passed
Push — master ( 281a84...6b6d15 )
by Odiseo
07:23
created

VendorsTrait::setVendors()   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 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Odiseo\SyliusVendorPlugin\Model;
4
5
use Doctrine\Common\Collections\ArrayCollection;
6
7
trait VendorsTrait
8
{
9
    /** @var ArrayCollection|VendorInterface[] */
10
    protected $vendors;
11
12
    /**
13
     * @inheritdoc
14
     */
15
    public function getVendors()
16
    {
17
        return $this->vendors;
18
    }
19
20
    /**
21
     * @inheritdoc
22
     */
23
    public function setVendors(ArrayCollection $vendors)
24
    {
25
        $this->vendors = $vendors;
26
    }
27
28
    /**
29
     * @inheritdoc
30
     */
31
    public function addVendor(VendorInterface $vendor)
32
    {
33
        if(!$this->vendors->contains($vendor)) {
34
            $this->vendors->add($vendor);
35
            $vendor->addProduct($this);
0 ignored issues
show
Bug introduced by
$this of type Odiseo\SyliusVendorPlugin\Model\VendorsTrait is incompatible with the type Odiseo\SyliusVendorPlugin\Model\ProductInterface expected by parameter $product of Odiseo\SyliusVendorPlugi...Interface::addProduct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

35
            $vendor->addProduct(/** @scrutinizer ignore-type */ $this);
Loading history...
36
        }
37
    }
38
39
    /**
40
     * @inheritdoc
41
     */
42
    public function removeVendor(VendorInterface $vendor)
43
    {
44
        if($this->vendors->contains($vendor)) {
45
            $this->vendors->removeElement($vendor);
46
            $vendor->removeProduct($this);
0 ignored issues
show
Bug introduced by
$this of type Odiseo\SyliusVendorPlugin\Model\VendorsTrait is incompatible with the type Odiseo\SyliusVendorPlugin\Model\ProductInterface expected by parameter $product of Odiseo\SyliusVendorPlugi...erface::removeProduct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

46
            $vendor->removeProduct(/** @scrutinizer ignore-type */ $this);
Loading history...
47
        }
48
    }
49
}