Terminal::getNatures()   A
last analyzed

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 0
1
<?php
2
3
namespace Loevgaard\DandomainAltapayBundle\Entity;
4
5
use Cocur\Slugify\Slugify;
6
use Doctrine\ORM\Mapping as ORM;
7
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
8
use Symfony\Component\Validator\Constraints as Assert;
9
10
/**
11
 * @ORM\Table(name="dandomain_altapay_terminals")
12
 * @ORM\Entity()
13
 * @ORM\HasLifecycleCallbacks
14
 *
15
 * We don't get any identifying information from Altapay other than the title of the terminal
16
 * therefore both the title and slug should be unique
17
 *
18
 * @UniqueEntity("title")
19
 * @UniqueEntity("slug")
20
 */
21
class Terminal
22
{
23
    /**
24
     * @var int
25
     *
26
     * @ORM\Id
27
     * @ORM\Column(name="id", type="integer")
28
     * @ORM\GeneratedValue(strategy="AUTO")
29
     */
30
    protected $id;
31
32
    /**
33
     * @var string
34
     *
35
     * @Assert\NotBlank()
36
     * @Assert\Length(max="191")
37
     *
38
     * @ORM\Column(type="string", unique=true, length=191)
39
     */
40
    protected $title;
41
42
    /**
43
     * @var string
44
     *
45
     * @Assert\NotBlank()
46
     * @Assert\Length(max="191")
47
     *
48
     * @ORM\Column(name="slug", type="string", unique=true, length=191)
49
     */
50
    protected $slug;
51
52
    /**
53
     * @var string
54
     *
55
     * @Assert\NotBlank()
56
     * @Assert\Country()
57
     *
58
     * @ORM\Column(type="string")
59
     */
60
    protected $country;
61
62
    /**
63
     * @var array
64
     *
65
     * @ORM\Column(type="json_array")
66
     */
67
    protected $natures;
68
69
    /**
70
     * @var array
71
     *
72
     * @ORM\Column(type="json_array")
73
     */
74
    protected $currencies;
75
76
    /**
77
     * We only set the canonical title when we persist the object
78
     * This is because the canonical title is used for URLs and
79
     * changing this would require the user to change the URL in the
80
     * Dandomain gateway settings.
81
     *
82
     * @ORM\PrePersist
83
     */
84
    public function updateSlug()
85
    {
86
        $this->slug = (new Slugify())->slugify($this->title);
87
    }
88
89
    /**
90
     * @return int
91
     */
92
    public function getId()
93
    {
94
        return $this->id;
95
    }
96
97
    /**
98
     * @param $id
99
     *
100
     * @return Terminal
101
     */
102
    public function setId($id): self
103
    {
104
        $this->id = $id;
105
106
        return $this;
107
    }
108
109
    /**
110
     * @return null|string
111
     */
112
    public function getTitle(): ?string
113
    {
114
        return $this->title;
115
    }
116
117
    /**
118
     * @param string $title
119
     *
120
     * @return Terminal
121
     */
122
    public function setTitle(string $title): self
123
    {
124
        $this->title = $title;
125
126
        return $this;
127
    }
128
129
    /**
130
     * @return null|string
131
     */
132
    public function getSlug(): ?string
133
    {
134
        return $this->slug;
135
    }
136
137
    /**
138
     * @param string $slug
139
     *
140
     * @return Terminal
141
     */
142
    public function setSlug(string $slug): self
143
    {
144
        $this->slug = $slug;
145
146
        return $this;
147
    }
148
149
    /**
150
     * @return null|string
151
     */
152
    public function getCountry(): ?string
153
    {
154
        return $this->country;
155
    }
156
157
    /**
158
     * @param string $country
159
     *
160
     * @return Terminal
161
     */
162
    public function setCountry(string $country): self
163
    {
164
        $this->country = $country;
165
166
        return $this;
167
    }
168
169
    /**
170
     * @return array|null
171
     */
172
    public function getNatures(): ?array
173
    {
174
        return $this->natures;
175
    }
176
177
    /**
178
     * @param array $natures
179
     *
180
     * @return Terminal
181
     */
182
    public function setNatures(array $natures): self
183
    {
184
        $this->natures = $natures;
185
186
        return $this;
187
    }
188
189
    /**
190
     * @return array|null
191
     */
192
    public function getCurrencies(): ?array
193
    {
194
        return $this->currencies;
195
    }
196
197
    /**
198
     * @param array $currencies
199
     *
200
     * @return Terminal
201
     */
202
    public function setCurrencies(array $currencies): self
203
    {
204
        $this->currencies = $currencies;
205
206
        return $this;
207
    }
208
}
209