Completed
Push — master ( d81c19...f57266 )
by Kamil
20s
created

src/Sylius/Component/Core/Model/ProductImage.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Sylius\Component\Core\Model;
15
16
use Doctrine\Common\Collections\ArrayCollection;
17
use Doctrine\Common\Collections\Collection;
18
19
class ProductImage extends Image implements ProductImageInterface
20
{
21
    /**
22
     * @var Collection|ProductVariantInterface[]
23
     */
24
    protected $productVariants;
25
26
    public function __construct()
27
    {
28
        $this->productVariants = 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...oductVariantInterface>> of property $productVariants.

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...
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    public function hasProductVariants(): bool
35
    {
36
        return !$this->productVariants->isEmpty();
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    public function getProductVariants(): Collection
43
    {
44
        return $this->productVariants;
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50
    public function hasProductVariant(ProductVariantInterface $productVariant): bool
51
    {
52
        return $this->productVariants->contains($productVariant);
53
    }
54
55
    /**
56
     * {@inheritdoc}
57
     */
58
    public function addProductVariant(ProductVariantInterface $productVariant): void
59
    {
60
        $this->productVariants->add($productVariant);
61
    }
62
63
    /**
64
     * {@inheritdoc}
65
     */
66
    public function removeProductVariant(ProductVariantInterface $productVariant): void
67
    {
68
        if ($this->hasProductVariant($productVariant)) {
69
            $this->productVariants->removeElement($productVariant);
70
        }
71
    }
72
}
73