Completed
Push — develop ( 6a168f...92c47e )
by
unknown
12:16
created

JobSnapshot::getSearchableProperties()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * YAWIK
4
 *
5
 * @filesource
6
 * @copyright (c) 2013-2015 Cross Solution (http://cross-solution.de)
7
 * @license   MIT
8
 * @author    [email protected]
9
 */
10
11
namespace Jobs\Entity;
12
13
use Core\Entity\Snapshot as BaseEntity;
14
use Auth\Entity\UserInterface;
15
use Doctrine\Common\Collections\Collection;
16
use Organizations\Entity\OrganizationInterface;
17
use Core\Exception\ImmutablePropertyException;
18
use Core\Entity\PermissionsInterface;
19
use Organizations\Entity\Organization;
20
use Core\Entity\ModificationDateAwareEntityInterface;
21
use Core\Entity\SnapshotInterface;
22
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
23
use Core\Entity\EntityInterface;
24
25
/**
26
 * by using the BaseEntity,
27
 *
28
 * Class JobSnapshot
29
 * @package Jobs\Entity
30
 *
31
 * @ODM\EmbeddedDocument
32
 */
33
class JobSnapshot extends BaseEntity implements JobInterface, SnapshotInterface
34
{
35
36
    /**
37
     * @var String
38
     */
39
    protected $jobId;
40
41
    /**
42
     * unique ID of a job posting used by applications to reference
43
     * a job
44
     *
45
     * @var String
46
     * @ODM\String @ODM\Index
47
     **/
48
    protected $applyId;
49
50
    /**
51
     * title of a job posting
52
     *
53
     * @var String
54
     * @ODM\String
55
     */
56
    protected $title;
57
58
    /**
59
     * name of the publishing company
60
     *
61
     * @var String
62
     * @ODM\String
63
     */
64
    protected $company;
65
66
    /**
67
     * publishing company
68
     *
69
     * @var OrganizationInterface
70
     * @ODM\ReferenceOne (targetDocument="\Organizations\Entity\Organization", simple=true, inversedBy="jobs")
71
     * @ODM\Index
72
     */
73
    protected $organization;
74
75
76
    /**
77
     * Email Address, which is used to send notifications about e.g. new applications.
78
     *
79
     * @var String
80
     * @ODM\String
81
     **/
82
    protected $contactEmail;
83
84
    /**
85
     * the owner of a Job Posting
86
     *
87
     * @var UserInterface $user
88
     * @ODM\ReferenceOne(targetDocument="\Auth\Entity\User", simple=true)
89
     * @ODM\Index
90
     */
91
    protected $user;
92
93
    /**
94
     * all applications of a certain jobad
95
     *
96
     * @var Collection
97
     * @ODM\ReferenceMany(targetDocument="Applications\Entity\Application", simple=true, mappedBy="job",
98
     *                    repositoryMethod="loadApplicationsForJob")
99
     */
100
    protected $applications;
101
102
    /**
103
     * new applications
104
     *
105
     * @ODM\ReferenceMany(targetDocument="Applications\Entity\Application",
106
     *                    repositoryMethod="loadUnreadApplicationsForJob", mappedBy="job")
107
     * @var Int
108
     */
109
    protected $unreadApplications;
110
111
    /**
112
     * language of the job posting. Languages are ISO 639-1 coded
113
     *
114
     * @var String
115
     * @ODM\String
116
     */
117
    protected $language;
118
119
    /**
120
     * location of the job posting. This is a plain text, which describes the location in
121
     * search e.g. results.
122
     *
123
     * @var String
124
     * @ODM\String
125
     */
126
    protected $location;
127
128
    /**
129
     * locations of the job posting. This collection contains structured coordinates,
130
     * postal codes, city, region, and country names
131
     *
132
     * @var Collection
133
     * @ODM\EmbedMany(targetDocument="Location")
134
     */
135
    protected $locations;
136
137
    /**
138
     * Link which points to the job posting
139
     *
140
     * @var String
141
     * @ODM\String
142
     **/
143
    protected $link;
144
145
    /**
146
     * publishing date of a job posting
147
     *
148
     * @var String
149
     * @ODM\Field(type="tz_date")
150
     */
151
    protected $datePublishStart;
152
153
    /**
154
     * Status of the job posting
155
     *
156
     * @var Status
157
     * @ODM\EmbedOne(targetDocument="Status")
158
     * @ODM\Index
159
     */
160
    protected $status;
161
162
    /**
163
     * History on an job posting
164
     *
165
     * @var Collection
166
     * @ODM\EmbedMany(targetDocument="History")
167
     */
168
    protected $history;
169
170
    /**
171
     * Flag, privacy policy is accepted or not.
172
     *
173
     * @var bool
174
     * @ODM\Boolean
175
     */
176
    protected $termsAccepted;
177
178
    /**
179
     * Reference of a job opening, on which an applicant can refer to.
180
     *
181
     * @var String
182
     * @ODM\String
183
     */
184
    protected $reference;
185
186
    /**
187
     * Unified Resource Locator to the company-Logo
188
     *
189
     * @deprecated (use $organization->image->uri instead)
190
     * @var String
191
     * @ODM\String
192
     */
193
    protected $logoRef;
194
195
    /**
196
     * Template-Name
197
     *
198
     * @var String
199
     * @ODM\String
200
     */
201
    protected $template;
202
203
    /**
204
     * Application link.
205
     *
206
     * @var String
207
     * @ODM\String
208
     */
209
    protected $uriApply;
210
211
    /**
212
     * Unified Resource Locator the Yawik, which handled this job first - so
213
     * does know who is the one who has commited this job.
214
     *
215
     * @var String
216
     * @ODM\String
217
     */
218
    protected $uriPublisher;
219
220
    /**
221
     * The ATS mode entity.
222
     *
223
     * @var AtsMode
224
     * @ODM\EmbedOne(targetDocument="AtsMode")
225
     */
226
    protected $atsMode;
227
228
    /**
229
     * this must be enabled to use applications forms etc. for this job or
230
     * to see number of applications in the list of applications
231
     *
232
     * @var Boolean
233
     *
234
     * @ODM\Boolean
235
     */
236
    protected $atsEnabled;
237
238
    /**
239
     * Permissions
240
     *
241
     * @var PermissionsInterface
242
     * @ODM\EmbedOne(targetDocument="\Core\Entity\Permissions")
243
     */
244
    protected $permissions;
245
246
    /**
247
     *
248
     * @var TemplateValues
249
     * @ODM\EmbedOne(targetDocument="\Jobs\Entity\TemplateValues")
250
     */
251
    protected $templateValues;
252
253
254
    /**
255
     * Can contain various Portals
256
     *
257
     * @var array
258
     * @ODM\Collection*/
259
    protected $portals = array();
260
261
    /**
262
     * Flag indicating draft state of this job.
263
     *
264
     * @var bool
265
     * @ODM\Boolean
266
     */
267
    protected $isDraft = false;
268
269
    /**
270
     * @param $jobEntity
271
     */
272
    public function __construct()
273
    {
274
    }
275
276
    /**
277
     * transfer all attributes from the job-entity to the snapshot-entity
278
     *
279
     * @TODO this could go into an abstract class since it is nearly allways the same
280
     *
281
     * @param $source
282
     * @param $target
283
     * @return $this
284
     */
285
    protected function copyAttributes($source, $target)
286
    {
287
        $methods = array_filter(
288
            get_class_methods($source),
289
            function ($v) {
290
                return 3 < strlen($v) && strpos($v, 'get') === 0;
291
            }
292
        );
293
        // these attributes don't need to get copied
294
        $methods = array_diff($methods, array('getId', 'getHydrator', 'getHiringOrganizations'));
295
        $methods = array_map(
296
            function ($v) {
297
                return lcfirst(substr($v, 3));
298
            },
299
            $methods
300
        );
301
        foreach ($methods as $attribute) {
302
            $element = $source->$attribute;
303
            if (isset($element)) {
304
                // when the parameter is rigid you can't assign an non-existing elements
305
                if (method_exists($target, 'set' . lcfirst($attribute))) {
306
                    $target->$attribute = $element;
307
                }
308
            }
309
        }
310
        return $this;
311
    }
312
313
314
315
    /**
316
     * Gets the unique key used by applications to reference a job posting
317
     *
318
     * @param string $applyId
319
     * @throws \Core\Exception\ImmutablePropertyException
320
     */
321
    public function setApplyId($applyId)
322
    {
323
        throw new ImmutablePropertyException('applyId', $this);
324
    }
325
326
    /**
327
     * Sets a unique key used by applications to reference a job posting
328
     *
329
     * @return string
330
     */
331
    public function getApplyId()
332
    {
333
        return $this->applyId;
334
    }
335
336
    /**
337
     * checks, weather a job is enabled for getting applications
338
     * @deprecated since 0.19 - Use atsMode sub document via getAtsMode()
339
     * @return boolean
340
     */
341
    public function getAtsEnabled()
342
    {
343
        return $this->atsEnabled;
344
    }
345
346
    /**
347
     * enables a job add to receive applications
348
     *
349
     * @param boolean $atsEnabled
350
     * @deprecated since 0.19 - Use atsMode entity via setAtsMode()
351
     * @throws \Core\Exception\ImmutablePropertyException
352
     * @return \Jobs\Entity\Job
353
     */
354
    public function setAtsEnabled($atsEnabled)
355
    {
356
        throw new ImmutablePropertyException('atsEnabled', $this);
357
    }
358
359
    /**
360
     * Sets the ATS mode.
361
     *
362
     * @param AtsMode $mode
363
     * @throws \Core\Exception\ImmutablePropertyException
364
     *
365
     * @return self
366
     * @since 0.19
367
     */
368
    public function setAtsMode(AtsMode $mode)
369
    {
370
        throw new ImmutablePropertyException('atsMode', $this);
371
    }
372
373
    /**
374
     * Gets the ATS mode.
375
     *
376
     * @return AtsMode
377
     * @since 0.19
378
     */
379
    public function getAtsMode()
380
    {
381
        return $this->atsMode;
382
    }
383
384
    /**
385
     * Gets an URI for a job posting
386
     *
387
     * @return string
388
     */
389
    public function getLink()
390
    {
391
        return $this->link;
392
    }
393
394
    /**
395
     * Sets an URI for a job posting
396
     * @throws \Core\Exception\ImmutablePropertyException
397
     *
398
     * @param string $link
399
     */
400
    public function setLink($link)
401
    {
402
        throw new ImmutablePropertyException('link', $this);
403
    }
404
405
    /**
406
     * Gets the publishing date of a job posting
407
     *
408
     * @return string
409
     */
410
    public function getDatePublishStart()
411
    {
412
        return $this->datePublishStart;
413
    }
414
415
    /**
416
     * Sets the publishing date of a job posting
417
     * @throws \Core\Exception\ImmutablePropertyException
418
     *
419
     * @param $datePublishStart
420
     * @return string
421
     */
422
    public function setDatePublishStart($datePublishStart)
423
    {
424
        throw new ImmutablePropertyException('datePublishStart', $this);
425
    }
426
427
    /**
428
     * Gets the title of a job posting
429
     *
430
     * @return string $title
431
     */
432
    public function getTitle()
433
    {
434
        return $this->title;
435
    }
436
437
    /**
438
     * Sets the title of a job posting
439
     * @throws \Core\Exception\ImmutablePropertyException
440
     *
441
     * @param string $title
442
     */
443
    public function setTitle($title)
444
    {
445
        throw new ImmutablePropertyException('title', $this);
446
    }
447
448
    /**
449
     * Gets the organisation name, which offers the job posting
450
     *
451
     * @deprecated
452
     * @return string
453
     */
454
    public function getCompany()
455
    {
456
        return $this->company;
457
    }
458
459
    /**
460
     * Sets the organisation name, which offers a job posting
461
     * @throws \Core\Exception\ImmutablePropertyException
462
     *
463
     * @deprecated
464
     * @param string $company
465
     * @return JobInterface $job
466
     */
467
    public function setCompany($company)
468
    {
469
        throw new ImmutablePropertyException('company', $this);
470
    }
471
472
    /**
473
     * Gets the organisation, which offers the job posting
474
     *
475
     * @return OrganizationInterface
476
     */
477
    public function getOrganization()
478
    {
479
        return $this->organization;
480
    }
481
482
    /**
483
     * Sets the organization, which offers the job
484
     * @throws \Core\Exception\ImmutablePropertyException
485
     *
486
     * @param OrganizationInterface $organization
0 ignored issues
show
Documentation introduced by
Should the type for parameter $organization not be null|OrganizationInterface?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
487
     * @return JobInterface
488
     */
489
    public function setOrganization(OrganizationInterface $organization = null)
490
    {
491
        throw new ImmutablePropertyException('organization', $this);
492
    }
493
494
    /**
495
     * Sets the contact email of a job posting
496
     * @throws \Core\Exception\ImmutablePropertyException
497
     *
498
     * @param string $email
499
     * @return JobInterface $job
500
     */
501
    public function setContactEmail($email)
502
    {
503
        throw new ImmutablePropertyException('contactEmail', $this);
504
    }
505
506
    /**
507
     * Gets the contact email a job posting
508
     *
509
     * @return string
510
     */
511
    public function getContactEmail()
512
    {
513
        return $this->contactEmail;
514
    }
515
516
    /**
517
     * Sets the user, who owns a job posting
518
     * @throws \Core\Exception\ImmutablePropertyException
519
     *
520
     * @param UserInterface $user
521
     * @return JobInterface $job
522
     */
523
    public function setUser(UserInterface $user)
524
    {
525
        throw new ImmutablePropertyException('userInterface', $this);
526
    }
527
528
    /**
529
     * Gets the user, who owns a job posting
530
     *
531
     * @return UserInterface $user
532
     */
533
    public function getUser()
534
    {
535
        return $this->user;
536
    }
537
538
    /**
539
     * Gets the link to the application form
540
     *
541
     * @return String
542
     */
543
    public function getUriApply()
544
    {
545
        return $this->uriApply;
546
    }
547
548
    /**
549
     * Sets the Link to the application form
550
     * @throws \Core\Exception\ImmutablePropertyException
551
     *
552
     * @param String $uriApply
553
     * @return \Jobs\Entity\Job
554
     */
555
    public function setUriApply($uriApply)
556
    {
557
        throw new ImmutablePropertyException('uriApply', $this);
558
    }
559
560
    /**
561
     * Gets the URI of the publisher
562
     *
563
     * @return String
564
     */
565
    public function getUriPublisher()
566
    {
567
        return $this->uriPublisher;
568
    }
569
570
    /**
571
     * Sets the URI of the publisher
572
     * @throws \Core\Exception\ImmutablePropertyException
573
     *
574
     * @param String $uriPublisher
575
     * @return \Jobs\Entity\Job
576
     */
577
    public function setUriPublisher($uriPublisher)
578
    {
579
        throw new ImmutablePropertyException('uriPublisher', $this);
580
    }
581
582
    /**
583
     * Sets the language of a job posting
584
     * @throws \Core\Exception\ImmutablePropertyException
585
     *
586
     * @param string $language
587
     */
588
    public function setLanguage($language)
589
    {
590
        throw new ImmutablePropertyException('language', $this);
591
    }
592
593
    /**
594
     * Gets the language of a job posting
595
     *
596
     * @return string
597
     */
598
    public function getLanguage()
599
    {
600
        return $this->language;
601
    }
602
603
    /**
604
     * Sets the location of a job posting
605
     * @throws \Core\Exception\ImmutablePropertyException
606
     *
607
     * @param string $location
608
     */
609
    public function setLocation($location)
610
    {
611
        throw new ImmutablePropertyException('location', $this);
612
    }
613
614
    /**
615
     * Gets the location of a job posting
616
     *
617
     * @return string
618
     */
619
    public function getLocation()
620
    {
621
        return $this->location;
622
    }
623
624
    /**
625
     * Sets locations of a job posting
626
     * @throws \Core\Exception\ImmutablePropertyException
627
     *
628
     * @param string $locations
629
     */
630
    public function setLocations($locations)
631
    {
632
        throw new ImmutablePropertyException('locations', $this);
633
    }
634
635
    /**
636
     * Gets locations of a job posting
637
     *
638
     * @return string
0 ignored issues
show
Documentation introduced by
Should the return type not be Collection?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
639
     */
640
    public function getLocations()
641
    {
642
        return $this->locations;
643
    }
644
645
    /**
646
     * Sets applications for a job posting
647
     * @throws \Core\Exception\ImmutablePropertyException
648
     *
649
     * @param Collection $applications
650
     */
651
    public function setApplications(Collection $applications)
652
    {
653
        throw new ImmutablePropertyException('applications', $this);
654
    }
655
656
    /**
657
     * Gets applications for a job posting
658
     *
659
     * @return Collection $applications
660
     */
661
    public function getApplications()
662
    {
663
        return $this->applications;
664
    }
665
666
    /**
667
     * Sets Status of a job posting
668
     * @throws \Core\Exception\ImmutablePropertyException
669
     *
670
     * @param string $status
671
     */
672
    public function setStatus($status)
673
    {
674
        throw new ImmutablePropertyException('status', $this);
675
    }
676
677
    /**
678
     * Gets applications for a job posting
679
     *
680
     * @return string
0 ignored issues
show
Documentation introduced by
Should the return type not be Status?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
681
     */
682
    public function getStatus()
683
    {
684
        return $this->status;
685
    }
686
687
    /**
688
     * Sets the collection of history entities.
689
     * @throws \Core\Exception\ImmutablePropertyException
690
     *
691
     * @param Collection $history
692
     * @return JobInterface
693
     */
694
    public function setHistory(Collection $history)
695
    {
696
        throw new ImmutablePropertyException('status', $this);
697
    }
698
699
    /**
700
     * Gets the collection of history entities.
701
     *
702
     * @return Collection
703
     */
704
    public function getHistory()
705
    {
706
        return $this->history;
707
    }
708
709
    /**
710
     * Sets the terms and conditions accepted flag.
711
     * @throws \Core\Exception\ImmutablePropertyException
712
     *
713
     * @param bool $flag
714
     * @return self
715
     */
716
    public function setTermsAccepted($flag)
717
    {
718
        throw new ImmutablePropertyException('termsAccepted', $this);
719
    }
720
721
    /**
722
     * Gets the terms and conditions accepted flag.
723
     *
724
     * @return bool
725
     */
726
    public function getTermsAccepted()
727
    {
728
        return $this->termsAccepted;
729
    }
730
731
    /**
732
     * Sets a reference for a job posting, used by the
733
     * organisation offering the job.
734
     *
735
     * @throws \Core\Exception\ImmutablePropertyException
736
     * @param string $reference
737
     */
738
    public function setReference($reference)
739
    {
740
        throw new ImmutablePropertyException('reference', $this);
741
    }
742
743
    /**
744
     * Gets a reference for a job posting, used by the
745
     * organisation offering the job.
746
     *
747
     * @return string $reference
748
     */
749
    public function getReference()
750
    {
751
        return $this->reference;
752
    }
753
754
    /**
755
     * Sets the list of channels where a job opening should be published
756
     *
757
     * @throws \Core\Exception\ImmutablePropertyException
758
     * @param Array $portals
759
     */
760
    public function setPortals(array $portals)
761
    {
762
        throw new ImmutablePropertyException('portals', $this);
763
    }
764
765
    /**
766
     * Gets the list of channels where the job opening should be published
767
     *
768
     * @return Array
0 ignored issues
show
Documentation introduced by
Should the return type not be array|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
769
     */
770
    public function getPortals()
771
    {
772
        $this->portals;
773
    }
774
775
    /**
776
     * Gets the permissions entity.
777
     *
778
     * @return PermissionsInterface
779
     */
780
    public function getPermissions()
781
    {
782
        return $this->permissions;
783
    }
784
785
    /**
786
     * the permissions must be mutable because of a flaw in the design of an upper class
787
     *
788
     * @param PermissionsInterface $permissions
789
     * @return $this
790
     */
791
    public function setPermissions(PermissionsInterface $permissions)
792
    {
793
        $this->permissions = $permissions;
794
        return $this;
795
    }
796
797
    /**
798
     * Gets the Values of a job template
799
     *
800
     * @return TemplateValues
801
     */
802
    public function getTemplateValues()
803
    {
804
        return $this->templateValues;
805
    }
806
807
    /**
808
     * @param EntityInterface $templateValues
0 ignored issues
show
Documentation introduced by
Should the type for parameter $templateValues not be null|EntityInterface?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
809
     * @return $this
810
     */
811
    public function setTemplateValues(EntityInterface $templateValues = null)
812
    {
813
        $this->templateValues = $templateValues;
0 ignored issues
show
Documentation Bug introduced by
It seems like $templateValues can also be of type object<Core\Entity\EntityInterface>. However, the property $templateValues is declared as type object<Jobs\Entity\TemplateValues>. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
814
        return $this;
815
    }
816
817
    /**
818
     * Returns the string identifier of the Resource
819
     *
820
     * @return null|string
821
     */
822
    public function getResourceId()
823
    {
824
        return null;
825
    }
826
}
827