SpiegazioneSessioneCampoCreateEvent::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 7
Ratio 100 %

Importance

Changes 0
Metric Value
dl 7
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 2
1
<?php
2
3
namespace BitPrepared\Bundle\FormazioneBundle\Domain\Events;
4
5
/**
6
 * Event create for Aggregate Root SpiegazioneSessioneCampo
7
 */
8 View Code Duplication
final class SpiegazioneSessioneCampoCreateEvent implements DomainEvent
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
9
{
10
    /**
11
     * quando accade l'evento
12
     *
13
     * @var \DateTime
14
     */
15
    private $occurredOn;
16
17
    /**
18
     * id dell'aggregato root relativo all'evento
19
     *
20
     * @var int
21
     */
22
    private $aggregateId;
23
24
    /**
25
     * proprietà dell'evento
26
     *
27
     * @var array
28
     */
29
    private $properties;
30
31
    /**
32
     * costruttore
33
     */
34
    final public function __construct($aggregateId, array $properties = null)
0 ignored issues
show
Coding Style introduced by
Unnecessary FINAL modifier in FINAL class
Loading history...
35
    {
36
        // autoinizialize
37
        $this->occurredOn = new \DateTime();
38
        $this->aggregateId = $aggregateId;
39
        $this->properties = $properties;
0 ignored issues
show
Documentation Bug introduced by
It seems like $properties can be null. However, the property $properties is declared as array. Maybe change the type of the property to array|null or add a type check?

Our type inference engine has found an assignment of a scalar value (like a string, an integer or null) to a property which is an array.

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

To type hint that a parameter can be either an array or null, you can set a type hint of array and a default value of null. The PHP interpreter will then accept both an array or null for that parameter.

function aContainsB(array $needle = null, array  $haystack) {
    if (!$needle) {
        return false;
    }

    return array_intersect($haystack, $needle) == $haystack;
}

The function can be called with either null or an array for the parameter $needle but will only accept an array as $haystack.

Loading history...
40
    }
41
42
    /**
43
     * @return \DateTime
44
     */
45
    final public function getOccurredOn()
0 ignored issues
show
Coding Style introduced by
Unnecessary FINAL modifier in FINAL class
Loading history...
46
    {
47
        return $this->occurredOn;
48
    }
49
50
    /**
51
     * @return int
52
     */
53
    final public function getAggregateId()
0 ignored issues
show
Coding Style introduced by
Unnecessary FINAL modifier in FINAL class
Loading history...
54
    {
55
        return $this->aggregateId;
56
    }
57
58
    /**
59
     * @return array
60
     */
61
    final public function getProperties()
0 ignored issues
show
Coding Style introduced by
Unnecessary FINAL modifier in FINAL class
Loading history...
62
    {
63
        return $this->properties;
64
    }
65
}
66