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

src/Sylius/Component/Core/Model/Promotion.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
use Sylius\Component\Channel\Model\ChannelInterface as BaseChannelInterface;
19
use Sylius\Component\Promotion\Model\Promotion as BasePromotion;
20
21
class Promotion extends BasePromotion implements PromotionInterface
22
{
23
    /**
24
     * @var ChannelInterface[]|Collection
25
     */
26
    protected $channels;
27
28
    public function __construct()
29
    {
30
        parent::__construct();
31
32
        $this->channels = 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 array<integer,object<Syl...Collections\Collection> of property $channels.

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...
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function getChannels(): Collection
39
    {
40
        return $this->channels;
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function addChannel(BaseChannelInterface $channel): void
47
    {
48
        if (!$this->hasChannel($channel)) {
49
            $this->channels->add($channel);
50
        }
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    public function removeChannel(BaseChannelInterface $channel): void
57
    {
58
        if ($this->hasChannel($channel)) {
59
            $this->channels->removeElement($channel);
60
        }
61
    }
62
63
    /**
64
     * {@inheritdoc}
65
     */
66
    public function hasChannel(BaseChannelInterface $channel): bool
67
    {
68
        return $this->channels->contains($channel);
69
    }
70
}
71