Company::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Veslo project <https://github.com/symfony-doge/veslo>.
5
 *
6
 * (C) 2019-2021 Pavel Petrov <[email protected]>.
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * @license https://opensource.org/licenses/GPL-3.0 GPL-3.0
12
 */
13
14
declare(strict_types=1);
15
16
namespace Veslo\AnthillBundle\Entity;
17
18
use DateTimeInterface;
19
use Doctrine\Common\Collections\ArrayCollection;
20
use Doctrine\Common\Collections\Collection;
21
use Doctrine\ORM\Mapping as ORM;
22
use Gedmo\Mapping\Annotation as Gedmo;
23
24
/**
25
 * Company
26
 *
27
 * @ORM\Table(name="anthill_company")
28
 * @ORM\Entity
29
 * @ORM\Cache(usage="READ_ONLY", region="vacancies")
30
 * @Gedmo\Loggable(logEntryClass="Veslo\AnthillBundle\Entity\Company\History\Entry")
31
 * @Gedmo\SoftDeleteable(fieldName="deletionDate", hardDelete=false)
32
 */
33
class Company
34
{
35
    /**
36
     * Company identifier
37
     *
38
     * @var int
39
     *
40
     * @ORM\Column(name="id", type="integer", options={"comment": "Company identifier"})
41
     * @ORM\Id
42
     * @ORM\GeneratedValue(strategy="AUTO")
43
     */
44
    private $id;
45
46
    /**
47
     * Company name
48
     *
49
     * @var string
50
     *
51
     * @ORM\Column(name="name", type="string", length=255, unique=true, options={"comment": "Company name"})
52
     * @Gedmo\Versioned
53
     */
54
    private $name;
55
56
    /**
57
     * Company website URL
58
     *
59
     * @var string|null
60
     *
61
     * @ORM\Column(name="url", type="string", length=255, nullable=true, options={"comment": "Company website URL"})
62
     * @Gedmo\Versioned
63
     */
64
    private $url;
65
66
    /**
67
     * Company logo URL
68
     *
69
     * @var string|null
70
     *
71
     * @ORM\Column(name="logo_url", type="string", length=255, nullable=true, options={"comment": "Company logo URL"})
72
     * @Gedmo\Versioned
73
     */
74
    private $logoUrl;
75
76
    /**
77
     * Company vacancies
78
     *
79
     * @var Collection<Vacancy>
80
     *
81
     * @ORM\OneToMany(
82
     *     targetEntity="Veslo\AnthillBundle\Entity\Vacancy",
83
     *     mappedBy="company",
84
     *     fetch="EXTRA_LAZY",
85
     *     cascade={"remove"}
86
     * )
87
     */
88
    private $vacancies;
89
90
    /**
91
     * Last time when company data has been fetched from external job website
92
     *
93
     * @var DateTimeInterface
94
     *
95
     * @ORM\Column(
96
     *     name="synchronization_date",
97
     *     type="datetime",
98
     *     options={"comment": "Last time when company data has been fetched from external job website"}
99
     * )
100
     */
101
    private $synchronizationDate;
102
103
    /**
104
     * Date when company has been deleted
105
     *
106
     * @var DateTimeInterface
107
     *
108
     * @ORM\Column(
109
     *     name="deletion_date",
110
     *     type="datetime",
111
     *     nullable=true,
112
     *     options={"comment": "Date when company has been deleted"}
113
     * )
114
     */
115
    private $deletionDate;
116
117
    /**
118
     * Company constructor.
119
     */
120
    public function __construct()
121
    {
122
        $this->vacancies = new ArrayCollection();
123
    }
124
125
    /**
126
     * Returns company identifier
127
     *
128
     * @return int
129
     */
130
    public function getId(): int
131
    {
132
        return $this->id;
133
    }
134
135
    /**
136
     * Returns company name
137
     *
138
     * @return string
139
     */
140
    public function getName(): string
141
    {
142
        return $this->name;
143
    }
144
145
    /**
146
     * Sets company name
147
     *
148
     * @param string $name Company name
149
     *
150
     * @return void
151
     */
152
    public function setName(string $name): void
153
    {
154
        $this->name = $name;
155
    }
156
157
    /**
158
     * Returns company website URL
159
     *
160
     * @return string|null
161
     */
162
    public function getUrl(): ?string
163
    {
164
        return $this->url;
165
    }
166
167
    /**
168
     * Sets company website URL
169
     *
170
     * @param string|null $url Company website URL
171
     *
172
     * @return void
173
     */
174
    public function setUrl(?string $url): void
175
    {
176
        $this->url = $url;
177
    }
178
179
    /**
180
     * Returns company logo URL
181
     *
182
     * @return string|null Company logo URL
183
     */
184
    public function getLogoUrl(): ?string
185
    {
186
        return $this->logoUrl;
187
    }
188
189
    /**
190
     * Sets company logo URL
191
     *
192
     * @param string|null $logoUrl Company logo URL
193
     *
194
     * @return void
195
     */
196
    public function setLogoUrl(?string $logoUrl): void
197
    {
198
        $this->logoUrl = $logoUrl;
199
    }
200
201
    /**
202
     * Returns company vacancies
203
     *
204
     * @return Vacancy[]
205
     */
206
    public function getVacancies(): array
207
    {
208
        return $this->vacancies->toArray();
209
    }
210
211
    /**
212
     * Adds a vacancy relation to the company
213
     *
214
     * @param Vacancy $vacancy Vacancy
215
     *
216
     * @return void
217
     */
218
    public function addVacancy(Vacancy $vacancy): void
219
    {
220
        if ($this->vacancies->contains($vacancy)) {
221
            return;
222
        }
223
224
        $this->vacancies->add($vacancy);
225
        $vacancy->setCompany($this);
226
    }
227
228
    /**
229
     * Returns last time when company data has been changed
230
     *
231
     * @return DateTimeInterface
232
     */
233
    public function getSynchronizationDate(): DateTimeInterface
234
    {
235
        return $this->synchronizationDate;
236
    }
237
238
    /**
239
     * Sets last time when company data has been fetched from external job website
240
     *
241
     * @param DateTimeInterface $synchronizationDate Last time when company data has been changed
242
     *
243
     * @return void
244
     */
245
    public function setSynchronizationDate(DateTimeInterface $synchronizationDate): void
246
    {
247
        $this->synchronizationDate = $synchronizationDate;
248
    }
249
250
    /**
251
     * Returns date when company has been deleted
252
     *
253
     * @return DateTimeInterface
254
     */
255
    public function getDeletionDate(): DateTimeInterface
256
    {
257
        return $this->deletionDate;
258
    }
259
260
    /**
261
     * Sets date when company was deleted
262
     *
263
     * @param DateTimeInterface|null $deletionDate Date when company was deleted
264
     *
265
     * @return void
266
     */
267
    public function setDeletionDate(?DateTimeInterface $deletionDate): void
268
    {
269
        $this->deletionDate = $deletionDate;
270
    }
271
}
272