Passed
Push — master ( da72f5...6369ee )
by Jan
04:43
created

AbstractCompany::setPhoneNumber()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
4
 *
5
 * Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
6
 *
7
 * This program is free software; you can redistribute it and/or
8
 * modify it under the terms of the GNU General Public License
9
 * as published by the Free Software Foundation; either version 2
10
 * of the License, or (at your option) any later version.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 * GNU General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU General Public License
18
 * along with this program; if not, write to the Free Software
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
20
 */
21
22
declare(strict_types=1);
23
24
/**
25
 * Part-DB Version 0.4+ "nextgen"
26
 * Copyright (C) 2016 - 2019 Jan Böhmer
27
 * https://github.com/jbtronics.
28
 *
29
 * This program is free software; you can redistribute it and/or
30
 * modify it under the terms of the GNU General Public License
31
 * as published by the Free Software Foundation; either version 2
32
 * of the License, or (at your option) any later version.
33
 *
34
 * This program is distributed in the hope that it will be useful,
35
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
36
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
37
 * GNU General Public License for more details.
38
 *
39
 * You should have received a copy of the GNU General Public License
40
 * along with this program; if not, write to the Free Software
41
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
42
 */
43
44
namespace App\Entity\Base;
45
46
use Doctrine\ORM\Mapping as ORM;
47
use function is_string;
48
use Symfony\Component\Validator\Constraints as Assert;
49
50
/**
51
 * This abstract class is used for companies like suppliers or manufacturers.
52
 *
53
 * @ORM\MappedSuperclass()
54
 */
55
abstract class AbstractCompany extends AbstractPartsContainingDBElement
56
{
57
    /**
58
     * @var string The address of the company
59
     * @ORM\Column(type="string")
60
     */
61
    protected $address = '';
62
63
    /**
64
     * @var string The phone number of the company
65
     * @ORM\Column(type="string")
66
     */
67
    protected $phone_number = '';
68
69
    /**
70
     * @var string The fax number of the company
71
     * @ORM\Column(type="string")
72
     */
73
    protected $fax_number = '';
74
75
    /**
76
     * @var string The email address of the company
77
     * @ORM\Column(type="string")
78
     * @Assert\Email()
79
     */
80
    protected $email_address = '';
81
82
    /**
83
     * @var string The website of the company
84
     * @ORM\Column(type="string")
85
     * @Assert\Url()
86
     */
87
    protected $website = '';
88
89
    /**
90
     * @var string
91
     * @ORM\Column(type="string")
92
     */
93
    protected $auto_product_url = '';
94
95
    /********************************************************************************
96
     *
97
     *   Getters
98
     *
99
     *********************************************************************************/
100
101
    /**
102
     * Get the address.
103
     *
104
     * @return string the address of the company (with "\n" as line break)
105
     */
106
    public function getAddress(): string
107
    {
108
        return $this->address;
109
    }
110
111
    /**
112
     * Get the phone number.
113
     *
114
     * @return string the phone number of the company
115
     */
116
    public function getPhoneNumber(): string
117
    {
118
        return $this->phone_number;
119
    }
120
121
    /**
122
     * Get the fax number.
123
     *
124
     * @return string the fax number of the company
125
     */
126
    public function getFaxNumber(): string
127
    {
128
        return $this->fax_number;
129
    }
130
131
    /**
132
     * Get the e-mail address.
133
     *
134
     * @return string the e-mail address of the company
135
     */
136
    public function getEmailAddress(): string
137
    {
138
        return $this->email_address;
139
    }
140
141
    /**
142
     * Get the website.
143
     *
144
     * @return string the website of the company
145
     */
146
    public function getWebsite(): string
147
    {
148
        return $this->website;
149
    }
150
151
    /**
152
     * Get the link to the website of an article.
153
     *
154
     * @param string $partnr * NULL for returning the URL with a placeholder for the part number
155
     *                       * or the part number for returning the direct URL to the article
156
     *
157
     * @return string the link to the article
158
     */
159
    public function getAutoProductUrl($partnr = null): string
160
    {
161
        if (is_string($partnr)) {
162
            return str_replace('%PARTNUMBER%', $partnr, $this->auto_product_url);
163
        }
164
165
        return $this->auto_product_url;
166
    }
167
168
    /********************************************************************************
169
     *
170
     *   Setters
171
     *
172
     *********************************************************************************/
173
174
    /**
175
     * Set the addres.
176
     *
177
     * @param string $new_address the new address (with "\n" as line break)
178
     */
179
    public function setAddress(string $new_address): self
180
    {
181
        $this->address = $new_address;
182
183
        return $this;
184
    }
185
186
    /**
187
     * Set the phone number.
188
     *
189
     * @param string $new_phone_number the new phone number
190
     */
191
    public function setPhoneNumber(string $new_phone_number): self
192
    {
193
        $this->phone_number = $new_phone_number;
194
195
        return $this;
196
    }
197
198
    /**
199
     * Set the fax number.
200
     *
201
     * @param string $new_fax_number the new fax number
202
     */
203
    public function setFaxNumber(string $new_fax_number): self
204
    {
205
        $this->fax_number = $new_fax_number;
206
207
        return $this;
208
    }
209
210
    /**
211
     * Set the e-mail address.
212
     *
213
     * @param string $new_email_address the new e-mail address
214
     */
215
    public function setEmailAddress(string $new_email_address): self
216
    {
217
        $this->email_address = $new_email_address;
218
219
        return $this;
220
    }
221
222
    /**
223
     * Set the website.
224
     *
225
     * @param string $new_website the new website
226
     */
227
    public function setWebsite(string $new_website): self
228
    {
229
        $this->website = $new_website;
230
231
        return $this;
232
    }
233
234
    /**
235
     * Set the link to the website of an article.
236
     *
237
     * @param string $new_url the new URL with the placeholder %PARTNUMBER% for the part number
238
     */
239
    public function setAutoProductUrl(string $new_url): self
240
    {
241
        $this->auto_product_url = $new_url;
242
243
        return $this;
244
    }
245
}
246