Passed
Pull Request — master (#59)
by Raúl
04:04
created

Configuration::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php
2
3
namespace Pagantis\OrdersApiClient\Model\Order;
4
5
use Pagantis\OrdersApiClient\Model\AbstractModel;
6
use Pagantis\OrdersApiClient\Model\Order\Configuration\Channel;
7
use Pagantis\OrdersApiClient\Model\Order\Configuration\Urls;
8
9
/**
10
 * Class Configuration
11
 * @package Pagantis\OrdersApiClient\Model\Order
12
 */
13
class Configuration extends AbstractModel
14
{
15
    /**
16
     * @var Channel
17
     */
18
    protected $channel;
19
20
    /**
21
     * @var Urls
22
     */
23
    protected $urls;
24
25
    /**
26
     * @var string purchaseCountry valid country for your merchant account: ES,IT,PT,FR
27
     */
28
    protected $purchaseCountry;
29
30
    /**
31
     * @var array $allowedCountries
32
     */
33
    private $allowedCountries = array('IT','ES','PT','FR');
34
35
    /**
36
     * Configuration constructor.
37
     */
38
    public function __construct()
39
    {
40
        $this->channel = new Channel();
41
        $this->urls = new Urls();
42
    }
43
44
    /**
45
     * @return Channel
46
     */
47
    public function getChannel()
48
    {
49
        return $this->channel;
50
    }
51
52
    /**
53
     * @return Urls
54
     */
55
    public function getUrls()
56
    {
57
        return $this->urls;
58
    }
59
60
    /**
61
     * @return string
62
     */
63
    public function getPurchaseCountry()
64
    {
65
        return $this->purchaseCountry;
66
    }
67
68
    /**
69
     * @param Channel $channel
70
     *
71
     * @return Configuration
72
     */
73
    public function setChannel(Channel $channel)
74
    {
75
        $this->channel = $channel;
76
77
        return $this;
78
    }
79
80
    /**
81
     * @param Urls $urls
82
     *
83
     * @return Configuration
84
     */
85
    public function setUrls(Urls $urls)
86
    {
87
        $this->urls = $urls;
88
89
        return $this;
90
    }
91
92
    /**
93
     * @param string $purchaseCountry
94
     *
95
     * @return Configuration
96
     */
97
    public function setPurchaseCountry($purchaseCountry)
98
    {
99
        $upperPurchaseCountry = strtoupper($purchaseCountry);
100
        $this->purchaseCountry =
101
            in_array($upperPurchaseCountry, $this->allowedCountries) ? $upperPurchaseCountry : null;
102
103
        return $this;
104
    }
105
}
106