Completed
Push — master ( 677329...636a3e )
by Joachim
14:34
created

Terminal::updateSlug()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
namespace Loevgaard\DandomainAltapayBundle\Entity;
3
4
use Cocur\Slugify\Slugify;
5
use Doctrine\ORM\Mapping AS ORM;
6
7
/**
8
 * @ORM\MappedSuperclass
9
 * @ORM\HasLifecycleCallbacks
10
 */
11
abstract class Terminal implements TerminalInterface
12
{
13
    /**
14
     * @var string
15
     *
16
     * @ORM\Column(type="string")
17
     */
18
    protected $title;
19
20
    /**
21
     * @var string
22
     *
23
     * @ORM\Column(type="string", unique=true)
24
     */
25
    protected $slug;
26
27
    /**
28
     * @var string
29
     *
30
     * @ORM\Column(type="string")
31
     */
32
    protected $country;
33
34
    /**
35
     * @var array
36
     *
37
     * @ORM\Column(type="json_array")
38
     */
39
    protected $natures;
40
41
    /**
42
     * @var array
43
     *
44
     * @ORM\Column(type="json_array")
45
     */
46
    protected $currencies;
47
48
    /**
49
     * We only set the canonical title when we persist the object
50
     * This is because the canonical title is used for URLs and
51
     * changing this would require the user to change the URL in the
52
     * Dandomain gateway settings
53
     *
54
     * @ORM\PrePersist
55
     */
56
    public function updateSlug() {
57
        $this->slug = (new Slugify())->slugify($this->title);
58
    }
59
60
    /**
61
     * @inheritdoc
62
     */
63
    public function getTitle(): ?string
64
    {
65
        return $this->title;
66
    }
67
68
    /**
69
     * @inheritdoc
70
     */
71
    public function setTitle(string $title) : TerminalInterface
72
    {
73
        $this->title = $title;
74
        return $this;
75
    }
76
77
    /**
78
     * @inheritdoc
79
     */
80
    public function getSlug(): ?string
81
    {
82
        return $this->slug;
83
    }
84
85
    /**
86
     * @inheritdoc
87
     */
88
    public function setSlug(string $slug) : TerminalInterface
89
    {
90
        $this->slug = $slug;
91
        return $this;
92
    }
93
94
    /**
95
     * @inheritdoc
96
     */
97
    public function getCountry(): ?string
98
    {
99
        return $this->country;
100
    }
101
102
    /**
103
     * @inheritdoc
104
     */
105
    public function setCountry(string $country) : TerminalInterface
106
    {
107
        $this->country = $country;
108
        return $this;
109
    }
110
111
    /**
112
     * @inheritdoc
113
     */
114
    public function getNatures(): ?array
115
    {
116
        return $this->natures;
117
    }
118
119
    /**
120
     * @inheritdoc
121
     */
122
    public function setNatures(array $natures) : TerminalInterface
123
    {
124
        $this->natures = $natures;
125
        return $this;
126
    }
127
128
    /**
129
     * @inheritdoc
130
     */
131
    public function getCurrencies(): ?array
132
    {
133
        return $this->currencies;
134
    }
135
136
    /**
137
     * @inheritdoc
138
     */
139
    public function setCurrencies(array $currencies) : TerminalInterface
140
    {
141
        $this->currencies = $currencies;
142
        return $this;
143
    }
144
}