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

src/Sylius/Component/Core/Model/PaymentMethod.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 Payum\Core\Model\GatewayConfigInterface;
19
use Sylius\Component\Channel\Model\ChannelInterface as BaseChannelInterface;
20
use Sylius\Component\Payment\Model\PaymentMethod as BasePaymentMethod;
21
use Sylius\Component\Payment\Model\PaymentMethodTranslation;
22
23
class PaymentMethod extends BasePaymentMethod implements PaymentMethodInterface
24
{
25
    /**
26
     * @var Collection
27
     */
28
    protected $channels;
29
30
    /**
31
     * @var GatewayConfigInterface
32
     */
33
    protected $gatewayConfig;
34
35
    public function __construct()
36
    {
37
        parent::__construct();
38
39
        $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 object<Doctrine\Common\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...
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45
    public function getChannels(): Collection
46
    {
47
        return $this->channels;
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53
    public function hasChannel(BaseChannelInterface $channel): bool
54
    {
55
        return $this->channels->contains($channel);
56
    }
57
58
    /**
59
     * {@inheritdoc}
60
     */
61
    public function addChannel(BaseChannelInterface $channel): void
62
    {
63
        if (!$this->hasChannel($channel)) {
64
            $this->channels->add($channel);
65
        }
66
    }
67
68
    /**
69
     * {@inheritdoc}
70
     */
71
    public function removeChannel(BaseChannelInterface $channel): void
72
    {
73
        if ($this->hasChannel($channel)) {
74
            $this->channels->removeElement($channel);
75
        }
76
    }
77
78
    /**
79
     * {@inheritdoc}
80
     */
81
    public function setGatewayConfig(?GatewayConfigInterface $gatewayConfig): void
82
    {
83
        $this->gatewayConfig = $gatewayConfig;
84
    }
85
86
    /**
87
     * {@inheritdoc}
88
     */
89
    public function getGatewayConfig(): ?GatewayConfigInterface
90
    {
91
        return $this->gatewayConfig;
92
    }
93
94
    /**
95
     * {@inheritdoc}
96
     */
97
    public static function getTranslationClass(): string
98
    {
99
        return PaymentMethodTranslation::class;
100
    }
101
}
102