PompierEngagement   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 85
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 5
Bugs 2 Features 1
Metric Value
wmc 5
c 5
b 2
f 1
lcom 1
cbo 3
dl 0
loc 85
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 1
A getPompier() 0 4 1
A getSpecialitesEngagees() 0 8 2
A getMateriel() 0 4 1
1
<?php
2
3
namespace SDIS62\Core\Ops\Entity\Engagement;
4
5
use SDIS62\Core\Ops\Entity\Engagement;
6
use SDIS62\Core\Ops\Entity\Intervention;
7
use SDIS62\Core\Ops\Entity\Materiel;
8
use SDIS62\Core\Ops\Entity\Pompier;
9
10
class PompierEngagement extends Engagement
11
{
12
    /**
13
     * Type.
14
     *
15
     * @var string
16
     */
17
    protected $type = 'pompier';
18
19
    /**
20
     * Pompier associé.
21
     *
22
     * @var SDIS62\Core\Ops\Entity\Pompier
23
     */
24
    protected $pompier;
25
26
    /**
27
     * Matériel engagé.
28
     *
29
     * @var SDIS62\Core\Ops\Entity\Materiel
30
     */
31
    protected $materiel;
32
33
    /**
34
     * Spécialités engagées.
35
     *
36
     * @var array
37
     */
38
    protected $specialites_engagees;
39
40
    /**
41
     * Ajout d'un engagement de type pompier à une intervention.
42
     *
43
     * @param SDIS62\Core\Ops\Entity\Intervention $intervention
44
     * @param SDIS62\Core\Ops\Entity\Materiel     $materiel
45
     * @param SDIS62\Core\Ops\Entity\Pompier      $pompier
46
     * @param array                               $specialites_engagees
47
     */
48
    public function __construct(Intervention $intervention, Materiel $materiel, Pompier $pompier, array $specialites_engagees = [])
49
    {
50
        $this->pompier = $pompier;
0 ignored issues
show
Documentation Bug introduced by
It seems like $pompier of type object<SDIS62\Core\Ops\Entity\Pompier> is incompatible with the declared type object<SDIS62\Core\Ops\E...ore\Ops\Entity\Pompier> of property $pompier.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
51
        $this->pompier->addEngagement($this);
52
53
        $this->materiel = $materiel;
0 ignored issues
show
Documentation Bug introduced by
It seems like $materiel of type object<SDIS62\Core\Ops\Entity\Materiel> is incompatible with the declared type object<SDIS62\Core\Ops\E...re\Ops\Entity\Materiel> of property $materiel.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
54
        $this->materiel->addEngagement($this);
55
56
        $this->specialites_engagees = $specialites_engagees;
57
58
        parent::__construct($intervention, $materiel);
0 ignored issues
show
Unused Code introduced by
The call to Engagement::__construct() has too many arguments starting with $materiel.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
59
    }
60
61
    /**
62
     * Get the value of Pompier associé.
63
     *
64
     * @return SDIS62\Core\Ops\Entity\Pompier
65
     */
66
    public function getPompier()
67
    {
68
        return $this->pompier;
69
    }
70
71
    /**
72
     * Spécialitées engagées.
73
     *
74
     * @return array
75
     */
76
    public function getSpecialitesEngagees()
77
    {
78
        if (!($this->getPompier() instanceof Pompier\SpecialistePompier)) {
79
            return [];
80
        }
81
82
        return array_intersect($this->getPompier()->getSpecialites(), $this->specialites_engagees);
83
    }
84
85
    /**
86
     * Get the value of Matériel engagé.
87
     *
88
     * @return SDIS62\Core\Ops\Entity\Materiel
89
     */
90
    public function getMateriel()
91
    {
92
        return $this->materiel;
93
    }
94
}
95