Completed
Push — master ( bfd93b...a37554 )
by Kamil
15s
created

PaymentMethod::setGatewayConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
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
namespace Sylius\Component\Core\Model;
13
14
use Doctrine\Common\Collections\ArrayCollection;
15
use Doctrine\Common\Collections\Collection;
16
use Payum\Core\Model\GatewayConfigInterface;
17
use Sylius\Component\Channel\Model\ChannelInterface as BaseChannelInterface;
18
use Sylius\Component\Payment\Model\PaymentMethod as BasePaymentMethod;
19
use Sylius\Component\Payment\Model\PaymentMethodTranslation;
20
use Sylius\Component\Resource\Exception\UnsupportedMethodException;
21
22
/**
23
 * @author Mateusz Zalewski <[email protected]>
24
 */
25
class PaymentMethod extends BasePaymentMethod implements PaymentMethodInterface
26
{
27
    /**
28
     * @var Collection
29
     */
30
    protected $channels;
31
32
    /**
33
     * @var GatewayConfigInterface
34
     */
35
    protected $gatewayConfig;
36
37
    public function __construct()
38
    {
39
        parent::__construct();
40
41
        $this->channels = new ArrayCollection();
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    public function getChannels()
48
    {
49
        return $this->channels;
50
    }
51
52
    /**
53
     * {@inheritdoc}
54
     */
55
    public function hasChannel(BaseChannelInterface $channel)
56
    {
57
        return $this->channels->contains($channel);
58
    }
59
60
    /**
61
     * {@inheritdoc}
62
     */
63
    public function addChannel(BaseChannelInterface $channel)
64
    {
65
        if (!$this->hasChannel($channel)) {
66
            $this->channels->add($channel);
67
        }
68
    }
69
70
    /**
71
     * {@inheritdoc}
72
     */
73
    public function removeChannel(BaseChannelInterface $channel)
74
    {
75
        if ($this->hasChannel($channel)) {
76
            $this->channels->removeElement($channel);
77
        }
78
    }
79
80
    /**
81
     * {@inheritdoc}
82
     */
83
    public function setGatewayConfig(GatewayConfigInterface $gatewayConfig)
84
    {
85
        $this->gatewayConfig = $gatewayConfig;
86
    }
87
88
    /**
89
     * @return GatewayConfigInterface
90
     */
91
    public function getGatewayConfig()
92
    {
93
        return $this->gatewayConfig;
94
    }
95
96
    /**
97
     * {@inheritdoc}
98
     */
99
    public static function getTranslationClass()
100
    {
101
        return PaymentMethodTranslation::class;
102
    }
103
}
104