• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

CPS-IT / personio-jobs / 9544724083

17 Jun 2024 08:48AM UTC coverage: 3.61% (-0.03%) from 3.644%
9544724083

push

github

web-flow
Merge pull request #172 from CPS-IT/fix/work-experience

[BUGFIX] Allow `yearsOfExperience` to be empty

0 of 17 new or added lines in 2 files covered. (0.0%)

2 existing lines in 1 file now uncovered.

27 of 748 relevant lines covered (3.61%)

0.16 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/Classes/Domain/Model/Job.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of the TYPO3 CMS extension "personio_jobs".
7
 *
8
 * Copyright (C) 2023 Elias Häußler <e.haeussler@familie-redlich.de>
9
 *
10
 * This program is free software: you can redistribute it and/or modify
11
 * it under the terms of the GNU General Public License as published by
12
 * the Free Software Foundation, either version 2 of the License, or
13
 * (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 * GNU General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU General Public License
21
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22
 */
23

24
namespace CPSIT\Typo3PersonioJobs\Domain\Model;
25

26
use CPSIT\Typo3PersonioJobs\Enums\Job\EmploymentType;
27
use CPSIT\Typo3PersonioJobs\Enums\Job\Schedule;
28
use CPSIT\Typo3PersonioJobs\Enums\Job\Seniority;
29
use CPSIT\Typo3PersonioJobs\Enums\Job\YearsOfExperience;
30
use TYPO3\CMS\Extbase\Annotation as Extbase;
31
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
32
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
33

34
/**
35
 * Job
36
 *
37
 * @author Elias Häußler <e.haeussler@familie-redlich.de>
38
 * @license GPL-2.0-or-later
39
 */
40
class Job extends AbstractEntity implements \JsonSerializable
41
{
42
    final public const TABLE_NAME = 'tx_personiojobs_domain_model_job';
43

44
    protected int $personioId = 0;
45
    protected string $subcompany = '';
46
    protected string $office = '';
47
    protected string $department = '';
48
    protected string $recruitingCategory = '';
49
    protected string $name = '';
50

51
    /**
52
     * @Extbase\ORM\Cascade("remove")
53
     * @var ObjectStorage<JobDescription>
54
     */
55
    protected ObjectStorage $jobDescriptions;
56
    protected string $employmentType = '';
57
    protected string $seniority = '';
58
    protected string $schedule = '';
59
    protected string $yearsOfExperience = '';
60
    protected string $keywords = '';
61
    protected string $occupation = '';
62
    protected string $occupationCategory = '';
63
    protected ?\DateTime $createDate = null;
64
    protected string $contentHash = '';
65

66
    public function __construct()
×
67
    {
68
        $this->initializeStorageObjects();
×
69
    }
70

71
    /**
72
     * @param array{jobDescription: list<JobDescription>} $jobDescriptions
73
     */
74
    public static function fromApiResponse(
×
75
        int $id,
76
        ?string $subcompany,
77
        ?string $office,
78
        ?string $department,
79
        ?string $recruitingCategory,
80
        string $name,
81
        array $jobDescriptions,
82
        EmploymentType $employmentType,
83
        Seniority $seniority,
84
        Schedule $schedule,
85
        ?YearsOfExperience $yearsOfExperience,
86
        ?string $keywords,
87
        ?string $occupation,
88
        ?string $occupationCategory,
89
        \DateTime $createdAt,
90
    ): self {
91
        $job = new self();
×
92
        $job->personioId = $id;
×
93
        $job->subcompany = (string)$subcompany;
×
94
        $job->office = (string)$office;
×
95
        $job->department = (string)$department;
×
96
        $job->recruitingCategory = (string)$recruitingCategory;
×
97
        $job->name = $name;
×
98

99
        foreach ($jobDescriptions['jobDescription'] as $jobDescription) {
×
100
            $jobDescription->setJob($job);
×
101
            $job->addJobDescription($jobDescription);
×
102
        }
103

104
        $job->employmentType = $employmentType->value;
×
105
        $job->seniority = $seniority->value;
×
106
        $job->schedule = $schedule->value;
×
NEW
107
        $job->yearsOfExperience = $yearsOfExperience->value ?? '';
×
108
        $job->keywords = (string)$keywords;
×
109
        $job->occupation = (string)$occupation;
×
110
        $job->occupationCategory = (string)$occupationCategory;
×
111
        $job->createDate = $createdAt;
×
112
        $job->contentHash = $job->calculateHash();
×
113

114
        return $job;
×
115
    }
116

117
    protected function initializeStorageObjects(): void
×
118
    {
119
        $this->jobDescriptions = new ObjectStorage();
×
120
    }
121

122
    /**
123
     * @param int<1, max> $uid
124
     */
125
    public function setUid(int $uid): self
×
126
    {
127
        $this->uid = $uid;
×
128

129
        return $this;
×
130
    }
131

132
    public function getPersonioId(): int
×
133
    {
134
        return $this->personioId;
×
135
    }
136

137
    public function setPersonioId(int $personioId): self
×
138
    {
139
        $this->personioId = $personioId;
×
140

141
        return $this;
×
142
    }
143

144
    public function getSubcompany(): string
×
145
    {
146
        return $this->subcompany;
×
147
    }
148

149
    public function setSubcompany(string $subcompany): self
×
150
    {
151
        $this->subcompany = $subcompany;
×
152

153
        return $this;
×
154
    }
155

156
    public function getOffice(): string
×
157
    {
158
        return $this->office;
×
159
    }
160

161
    public function setOffice(string $office): self
×
162
    {
163
        $this->office = $office;
×
164

165
        return $this;
×
166
    }
167

168
    public function getDepartment(): string
×
169
    {
170
        return $this->department;
×
171
    }
172

173
    public function setDepartment(string $department): self
×
174
    {
175
        $this->department = $department;
×
176

177
        return $this;
×
178
    }
179

180
    public function getRecruitingCategory(): string
×
181
    {
182
        return $this->recruitingCategory;
×
183
    }
184

185
    public function setRecruitingCategory(string $recruitingCategory): self
×
186
    {
187
        $this->recruitingCategory = $recruitingCategory;
×
188

189
        return $this;
×
190
    }
191

192
    public function getName(): string
×
193
    {
194
        return $this->name;
×
195
    }
196

197
    public function setName(string $name): self
×
198
    {
199
        $this->name = $name;
×
200

201
        return $this;
×
202
    }
203

204
    /**
205
     * @return ObjectStorage<JobDescription>
206
     */
207
    public function getJobDescriptions(): ObjectStorage
×
208
    {
209
        return $this->jobDescriptions;
×
210
    }
211

212
    /**
213
     * @param ObjectStorage<JobDescription> $jobDescriptions
214
     */
215
    public function setJobDescriptions(ObjectStorage $jobDescriptions): self
×
216
    {
217
        $this->jobDescriptions = $jobDescriptions;
×
218

219
        return $this;
×
220
    }
221

222
    public function addJobDescription(JobDescription $jobDescription): self
×
223
    {
224
        $this->jobDescriptions->attach($jobDescription);
×
225

226
        return $this;
×
227
    }
228

229
    public function removeJobDescription(JobDescription $jobDescription): self
×
230
    {
231
        $this->jobDescriptions->detach($jobDescription);
×
232

233
        return $this;
×
234
    }
235

236
    public function getEmploymentType(): string
×
237
    {
238
        return $this->employmentType;
×
239
    }
240

241
    public function setEmploymentType(string $employmentType): self
×
242
    {
243
        $this->employmentType = $employmentType;
×
244

245
        return $this;
×
246
    }
247

248
    public function getSeniority(): string
×
249
    {
250
        return $this->seniority;
×
251
    }
252

253
    public function setSeniority(string $seniority): self
×
254
    {
255
        $this->seniority = $seniority;
×
256

257
        return $this;
×
258
    }
259

260
    public function getSchedule(): string
×
261
    {
262
        return $this->schedule;
×
263
    }
264

265
    public function setSchedule(string $schedule): self
×
266
    {
267
        $this->schedule = $schedule;
×
268

269
        return $this;
×
270
    }
271

272
    public function getYearsOfExperience(): string
×
273
    {
274
        return $this->yearsOfExperience;
×
275
    }
276

277
    public function setYearsOfExperience(string $yearsOfExperience): self
×
278
    {
279
        $this->yearsOfExperience = $yearsOfExperience;
×
280

281
        return $this;
×
282
    }
283

284
    public function getKeywords(): string
×
285
    {
286
        return $this->keywords;
×
287
    }
288

289
    public function setKeywords(string $keywords): self
×
290
    {
291
        $this->keywords = $keywords;
×
292

293
        return $this;
×
294
    }
295

296
    public function getOccupation(): string
×
297
    {
298
        return $this->occupation;
×
299
    }
300

301
    public function setOccupation(string $occupation): self
×
302
    {
303
        $this->occupation = $occupation;
×
304

305
        return $this;
×
306
    }
307

308
    public function getOccupationCategory(): string
×
309
    {
310
        return $this->occupationCategory;
×
311
    }
312

313
    public function setOccupationCategory(string $occupationCategory): self
×
314
    {
315
        $this->occupationCategory = $occupationCategory;
×
316

317
        return $this;
×
318
    }
319

320
    public function getCreateDate(): ?\DateTime
×
321
    {
322
        return $this->createDate;
×
323
    }
324

325
    public function setCreateDate(?\DateTime $createDate): self
×
326
    {
327
        $this->createDate = $createDate;
×
328

329
        return $this;
×
330
    }
331

332
    public function getContentHash(): string
×
333
    {
334
        return $this->contentHash;
×
335
    }
336

337
    public function recalculateContentHash(): self
×
338
    {
339
        $this->contentHash = $this->calculateHash();
×
340

341
        return $this;
×
342
    }
343

344
    /**
345
     * @return array<string, mixed>
346
     */
347
    public function jsonSerialize(): array
×
348
    {
349
        return [
×
350
            'personioId' => $this->personioId,
×
351
            'subcompany' => $this->subcompany,
×
352
            'office' => $this->office,
×
353
            'department' => $this->department,
×
354
            'recruitingCategory' => $this->recruitingCategory,
×
355
            'name' => $this->name,
×
356
            'jobDescriptions' => $this->jobDescriptions->toArray(),
×
357
            'employmentType' => $this->employmentType,
×
358
            'seniority' => $this->seniority,
×
359
            'schedule' => $this->schedule,
×
360
            'yearsOfExperience' => $this->yearsOfExperience,
×
361
            'keywords' => $this->keywords,
×
362
            'occupation' => $this->occupation,
×
363
            'occupationCategory' => $this->occupationCategory,
×
364
            'createDate' => $this->createDate?->getTimestamp(),
×
365
        ];
×
366
    }
367

368
    private function calculateHash(): string
×
369
    {
370
        return sha1(json_encode($this, JSON_THROW_ON_ERROR));
×
371
    }
372
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc