Completed
Push — develop ( e970db...c13c79 )
by
unknown
15:28 queued 07:58
created

JobSnapshot::getPortals()   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 - 2016 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\Field(type="string") @ODM\Index
47
     **/
48
    protected $applyId;
49
50
    /**
51
     * title of a job posting
52
     *
53
     * @var String
54
     * @ODM\Field(type="string")
55
     */
56
    protected $title;
57
58
    /**
59
     * name of the publishing company
60
     *
61
     * @var String
62
     * @ODM\Field(type="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\Field(type="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\Field(type="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\Field(type="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\Field(type="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
     * end date of a job posting
155
     *
156
     * @var String
157
     * @ODM\Field(type="tz_date")
158
     */
159
    protected $datePublishEnd;
160
161
    /**
162
     * Status of the job posting
163
     *
164
     * @var Status
165
     * @ODM\EmbedOne(targetDocument="Status")
166
     * @ODM\Index
167
     */
168
    protected $status;
169
170
    /**
171
     * History on an job posting
172
     *
173
     * @var Collection
174
     * @ODM\EmbedMany(targetDocument="History")
175
     */
176
    protected $history;
177
178
    /**
179
     * Flag, privacy policy is accepted or not.
180
     *
181
     * @var bool
182
     * @ODM\Boolean
183
     */
184
    protected $termsAccepted;
185
186
    /**
187
     * Reference of a job opening, on which an applicant can refer to.
188
     *
189
     * @var String
190
     * @ODM\Field(type="string")
191
     */
192
    protected $reference;
193
194
    /**
195
     * Unified Resource Locator to the company-Logo
196
     *
197
     * @deprecated (use $organization->image->uri instead)
198
     * @var String
199
     * @ODM\Field(type="string")
200
     */
201
    protected $logoRef;
202
203
    /**
204
     * Template-Name
205
     *
206
     * @var String
207
     * @ODM\Field(type="string")
208
     */
209
    protected $template;
210
211
    /**
212
     * Application link.
213
     *
214
     * @var String
215
     * @ODM\Field(type="string")
216
     */
217
    protected $uriApply;
218
219
    /**
220
     * Unified Resource Locator the Yawik, which handled this job first - so
221
     * does know who is the one who has commited this job.
222
     *
223
     * @var String
224
     * @ODM\Field(type="string")
225
     */
226
    protected $uriPublisher;
227
228
    /**
229
     * The ATS mode entity.
230
     *
231
     * @var AtsMode
232
     * @ODM\EmbedOne(targetDocument="AtsMode")
233
     */
234
    protected $atsMode;
235
236
    /**
237
     * this must be enabled to use applications forms etc. for this job or
238
     * to see number of applications in the list of applications
239
     *
240
     * @var Boolean
241
     *
242
     * @ODM\Boolean
243
     */
244
    protected $atsEnabled;
245
246
    /**
247
     * Permissions
248
     *
249
     * @var PermissionsInterface
250
     * @ODM\EmbedOne(targetDocument="\Core\Entity\Permissions")
251
     */
252
    protected $permissions;
253
254
    /**
255
     *
256
     * @var TemplateValues
257
     * @ODM\EmbedOne(targetDocument="\Jobs\Entity\TemplateValues")
258
     */
259
    protected $templateValues;
260
261
262
    /**
263
     * Can contain various Portals
264
     *
265
     * @var array
266
     * @ODM\Collection*/
267
    protected $portals = array();
268
269
    /**
270
     * Flag indicating draft state of this job.
271
     *
272
     * @var bool
273
     * @ODM\Boolean
274
     */
275
    protected $isDraft = false;
276
277
    /**
278
     * @param $jobEntity
279
     */
280
    public function __construct()
281
    {
282
    }
283
284
    /**
285
     * transfer all attributes from the job-entity to the snapshot-entity
286
     *
287
     * @TODO this could go into an abstract class since it is nearly allways the same
288
     *
289
     * @param $source
290
     * @param $target
291
     * @return $this
292
     */
293
    protected function copyAttributes($source, $target)
294
    {
295
        $methods = array_filter(
296
            get_class_methods($source),
297
            function ($v) {
298
                return 3 < strlen($v) && strpos($v, 'get') === 0;
299
            }
300
        );
301
        // these attributes don't need to get copied
302
        $methods = array_diff($methods, array('getId', 'getHydrator', 'getHiringOrganizations'));
303
        $methods = array_map(
304
            function ($v) {
305
                return lcfirst(substr($v, 3));
306
            },
307
            $methods
308
        );
309
        foreach ($methods as $attribute) {
310
            $element = $source->$attribute;
311
            if (isset($element)) {
312
                // when the parameter is rigid you can't assign an non-existing elements
313
                if (method_exists($target, 'set' . lcfirst($attribute))) {
314
                    $target->$attribute = $element;
315
                }
316
            }
317
        }
318
        return $this;
319
    }
320
321
322
323
    /**
324
     * Gets the unique key used by applications to reference a job posting
325
     *
326
     * @param string $applyId
327
     * @throws \Core\Exception\ImmutablePropertyException
328
     */
329
    public function setApplyId($applyId)
330
    {
331
        throw new ImmutablePropertyException('applyId', $this);
332
    }
333
334
    /**
335
     * Sets a unique key used by applications to reference a job posting
336
     *
337
     * @return string
338
     */
339
    public function getApplyId()
340
    {
341
        return $this->applyId;
342
    }
343
344
    /**
345
     * checks, weather a job is enabled for getting applications
346
     * @deprecated since 0.19 - Use atsMode sub document via getAtsMode()
347
     * @return boolean
348
     */
349
    public function getAtsEnabled()
350
    {
351
        return $this->atsEnabled;
352
    }
353
354
    /**
355
     * enables a job add to receive applications
356
     *
357
     * @param boolean $atsEnabled
358
     * @deprecated since 0.19 - Use atsMode entity via setAtsMode()
359
     * @throws \Core\Exception\ImmutablePropertyException
360
     * @return \Jobs\Entity\Job
361
     */
362
    public function setAtsEnabled($atsEnabled)
363
    {
364
        throw new ImmutablePropertyException('atsEnabled', $this);
365
    }
366
367
    /**
368
     * Sets the ATS mode.
369
     *
370
     * @param AtsMode $mode
371
     * @throws \Core\Exception\ImmutablePropertyException
372
     *
373
     * @return self
374
     * @since 0.19
375
     */
376
    public function setAtsMode(AtsMode $mode)
377
    {
378
        throw new ImmutablePropertyException('atsMode', $this);
379
    }
380
381
    /**
382
     * Gets the ATS mode.
383
     *
384
     * @return AtsMode
385
     * @since 0.19
386
     */
387
    public function getAtsMode()
388
    {
389
        return $this->atsMode;
390
    }
391
392
    /**
393
     * Gets an URI for a job posting
394
     *
395
     * @return string
396
     */
397
    public function getLink()
398
    {
399
        return $this->link;
400
    }
401
402
    /**
403
     * Sets an URI for a job posting
404
     * @throws \Core\Exception\ImmutablePropertyException
405
     *
406
     * @param string $link
407
     */
408
    public function setLink($link)
409
    {
410
        throw new ImmutablePropertyException('link', $this);
411
    }
412
413
    /**
414
     * Gets the publishing date of a job posting
415
     *
416
     * @return string
417
     */
418
    public function getDatePublishStart()
419
    {
420
        return $this->datePublishStart;
421
    }
422
423
    /**
424
     * Sets the publishing date of a job posting
425
     * @throws \Core\Exception\ImmutablePropertyException
426
     *
427
     * @param $datePublishStart
428
     * @return string
429
     */
430
    public function setDatePublishStart($datePublishStart)
431
    {
432
        throw new ImmutablePropertyException('datePublishStart', $this);
433
    }
434
435
    /**
436
     * Gets the end date for publishing of a job posting
437
     *
438
     * @return string
439
     */
440
    public function getDatePublishEnd()
441
    {
442
        return $this->datePublishStart;
443
    }
444
445
    /**
446
     * Sets the publishing date of a job posting
447
     * @throws \Core\Exception\ImmutablePropertyException
448
     *
449
     * @param $datePublishStart
450
     * @return string
451
     */
452
    public function setDatePublishEnd($datePublishEnd)
453
    {
454
        throw new ImmutablePropertyException('datePublishEnd', $this);
455
    }
456
457
    /**
458
     * Gets the title of a job posting
459
     *
460
     * @return string $title
461
     */
462
    public function getTitle()
463
    {
464
        return $this->title;
465
    }
466
467
    /**
468
     * Sets the title of a job posting
469
     * @throws \Core\Exception\ImmutablePropertyException
470
     *
471
     * @param string $title
472
     */
473
    public function setTitle($title)
474
    {
475
        throw new ImmutablePropertyException('title', $this);
476
    }
477
478
    /**
479
     * Gets the organisation name, which offers the job posting
480
     *
481
     * @deprecated
482
     * @return string
483
     */
484
    public function getCompany()
485
    {
486
        return $this->company;
487
    }
488
489
    /**
490
     * Sets the organisation name, which offers a job posting
491
     * @throws \Core\Exception\ImmutablePropertyException
492
     *
493
     * @deprecated
494
     * @param string $company
495
     * @return JobInterface $job
496
     */
497
    public function setCompany($company)
498
    {
499
        throw new ImmutablePropertyException('company', $this);
500
    }
501
502
    /**
503
     * Gets the organisation, which offers the job posting
504
     *
505
     * @return OrganizationInterface
506
     */
507
    public function getOrganization()
508
    {
509
        return $this->organization;
510
    }
511
512
    /**
513
     * Sets the organization, which offers the job
514
     * @throws \Core\Exception\ImmutablePropertyException
515
     *
516
     * @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...
517
     * @return JobInterface
518
     */
519
    public function setOrganization(OrganizationInterface $organization = null)
520
    {
521
        throw new ImmutablePropertyException('organization', $this);
522
    }
523
524
    /**
525
     * Sets the contact email of a job posting
526
     * @throws \Core\Exception\ImmutablePropertyException
527
     *
528
     * @param string $email
529
     * @return JobInterface $job
530
     */
531
    public function setContactEmail($email)
532
    {
533
        throw new ImmutablePropertyException('contactEmail', $this);
534
    }
535
536
    /**
537
     * Gets the contact email a job posting
538
     *
539
     * @return string
540
     */
541
    public function getContactEmail()
542
    {
543
        return $this->contactEmail;
544
    }
545
546
    /**
547
     * Sets the user, who owns a job posting
548
     * @throws \Core\Exception\ImmutablePropertyException
549
     *
550
     * @param UserInterface $user
551
     * @return JobInterface $job
552
     */
553
    public function setUser(UserInterface $user)
554
    {
555
        throw new ImmutablePropertyException('userInterface', $this);
556
    }
557
558
    /**
559
     * Gets the user, who owns a job posting
560
     *
561
     * @return UserInterface $user
562
     */
563
    public function getUser()
564
    {
565
        return $this->user;
566
    }
567
568
    /**
569
     * Gets the link to the application form
570
     *
571
     * @return String
572
     */
573
    public function getUriApply()
574
    {
575
        return $this->uriApply;
576
    }
577
578
    /**
579
     * Sets the Link to the application form
580
     * @throws \Core\Exception\ImmutablePropertyException
581
     *
582
     * @param String $uriApply
583
     * @return \Jobs\Entity\Job
584
     */
585
    public function setUriApply($uriApply)
586
    {
587
        throw new ImmutablePropertyException('uriApply', $this);
588
    }
589
590
    /**
591
     * Gets the URI of the publisher
592
     *
593
     * @return String
594
     */
595
    public function getUriPublisher()
596
    {
597
        return $this->uriPublisher;
598
    }
599
600
    /**
601
     * Sets the URI of the publisher
602
     * @throws \Core\Exception\ImmutablePropertyException
603
     *
604
     * @param String $uriPublisher
605
     * @return \Jobs\Entity\Job
606
     */
607
    public function setUriPublisher($uriPublisher)
608
    {
609
        throw new ImmutablePropertyException('uriPublisher', $this);
610
    }
611
612
    /**
613
     * Sets the language of a job posting
614
     * @throws \Core\Exception\ImmutablePropertyException
615
     *
616
     * @param string $language
617
     */
618
    public function setLanguage($language)
619
    {
620
        throw new ImmutablePropertyException('language', $this);
621
    }
622
623
    /**
624
     * Gets the language of a job posting
625
     *
626
     * @return string
627
     */
628
    public function getLanguage()
629
    {
630
        return $this->language;
631
    }
632
633
    /**
634
     * Sets the location of a job posting
635
     * @throws \Core\Exception\ImmutablePropertyException
636
     *
637
     * @param string $location
638
     */
639
    public function setLocation($location)
640
    {
641
        throw new ImmutablePropertyException('location', $this);
642
    }
643
644
    /**
645
     * Gets the location of a job posting
646
     *
647
     * @return string
648
     */
649
    public function getLocation()
650
    {
651
        return $this->location;
652
    }
653
654
    /**
655
     * Sets locations of a job posting
656
     * @throws \Core\Exception\ImmutablePropertyException
657
     *
658
     * @param string $locations
659
     */
660
    public function setLocations($locations)
661
    {
662
        throw new ImmutablePropertyException('locations', $this);
663
    }
664
665
    /**
666
     * Gets locations of a job posting
667
     *
668
     * @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...
669
     */
670
    public function getLocations()
671
    {
672
        return $this->locations;
673
    }
674
675
    /**
676
     * Sets applications for a job posting
677
     * @throws \Core\Exception\ImmutablePropertyException
678
     *
679
     * @param Collection $applications
680
     */
681
    public function setApplications(Collection $applications)
682
    {
683
        throw new ImmutablePropertyException('applications', $this);
684
    }
685
686
    /**
687
     * Gets applications for a job posting
688
     *
689
     * @return Collection $applications
690
     */
691
    public function getApplications()
692
    {
693
        return $this->applications;
694
    }
695
696
    /**
697
     * Sets Status of a job posting
698
     * @throws \Core\Exception\ImmutablePropertyException
699
     *
700
     * @param string $status
701
     */
702
    public function setStatus($status)
703
    {
704
        throw new ImmutablePropertyException('status', $this);
705
    }
706
707
    /**
708
     * Gets applications for a job posting
709
     *
710
     * @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...
711
     */
712
    public function getStatus()
713
    {
714
        return $this->status;
715
    }
716
717
    /**
718
     * Sets the collection of history entities.
719
     * @throws \Core\Exception\ImmutablePropertyException
720
     *
721
     * @param Collection $history
722
     * @return JobInterface
723
     */
724
    public function setHistory(Collection $history)
725
    {
726
        throw new ImmutablePropertyException('status', $this);
727
    }
728
729
    /**
730
     * Gets the collection of history entities.
731
     *
732
     * @return Collection
733
     */
734
    public function getHistory()
735
    {
736
        return $this->history;
737
    }
738
739
    /**
740
     * Sets the terms and conditions accepted flag.
741
     * @throws \Core\Exception\ImmutablePropertyException
742
     *
743
     * @param bool $flag
744
     * @return self
745
     */
746
    public function setTermsAccepted($flag)
747
    {
748
        throw new ImmutablePropertyException('termsAccepted', $this);
749
    }
750
751
    /**
752
     * Gets the terms and conditions accepted flag.
753
     *
754
     * @return bool
755
     */
756
    public function getTermsAccepted()
757
    {
758
        return $this->termsAccepted;
759
    }
760
761
    /**
762
     * Sets a reference for a job posting, used by the
763
     * organisation offering the job.
764
     *
765
     * @throws \Core\Exception\ImmutablePropertyException
766
     * @param string $reference
767
     */
768
    public function setReference($reference)
769
    {
770
        throw new ImmutablePropertyException('reference', $this);
771
    }
772
773
    /**
774
     * Gets a reference for a job posting, used by the
775
     * organisation offering the job.
776
     *
777
     * @return string $reference
778
     */
779
    public function getReference()
780
    {
781
        return $this->reference;
782
    }
783
784
    /**
785
     * Sets the list of channels where a job opening should be published
786
     *
787
     * @throws \Core\Exception\ImmutablePropertyException
788
     * @param Array $portals
789
     */
790
    public function setPortals(array $portals)
791
    {
792
        throw new ImmutablePropertyException('portals', $this);
793
    }
794
795
    /**
796
     * Gets the list of channels where the job opening should be published
797
     *
798
     * @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...
799
     */
800
    public function getPortals()
801
    {
802
        $this->portals;
803
    }
804
805
    /**
806
     * Gets the permissions entity.
807
     *
808
     * @return PermissionsInterface
809
     */
810
    public function getPermissions()
811
    {
812
        return $this->permissions;
813
    }
814
815
    /**
816
     * the permissions must be mutable because of a flaw in the design of an upper class
817
     *
818
     * @param PermissionsInterface $permissions
819
     * @return $this
820
     */
821
    public function setPermissions(PermissionsInterface $permissions)
822
    {
823
        $this->permissions = $permissions;
824
        return $this;
825
    }
826
827
    /**
828
     * Gets the Values of a job template
829
     *
830
     * @return TemplateValues
831
     */
832
    public function getTemplateValues()
833
    {
834
        return $this->templateValues;
835
    }
836
837
    /**
838
     * @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...
839
     * @return $this
840
     */
841
    public function setTemplateValues(EntityInterface $templateValues = null)
842
    {
843
        $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...
844
        return $this;
845
    }
846
847
    /**
848
     * Returns the string identifier of the Resource
849
     *
850
     * @return null|string
851
     */
852
    public function getResourceId()
853
    {
854
        return null;
855
    }
856
}
857