SpiegazioneSessioneCampoCreateEvent   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 83
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 0
dl 83
loc 83
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 9 9 1
A getSpecial() 4 4 1
A setSpecial() 4 4 1
A getOccurredOn() 4 4 1
A getAggregateId() 4 4 1
A getProperties() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace BitPrepared\Bundle\EventBundle\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
     * special value
12
     *
13
     * @var int
14
     */
15
    private $special;
16
17
    /**
18
     * quando accade l'evento
19
     *
20
     * @var \DateTime
21
     */
22
    private $occurredOn;
23
24
    /**
25
     * id dell'aggregato root relativo all'evento
26
     *
27
     * @var int
28
     */
29
    private $aggregateId;
30
31
    /**
32
     * proprietà dell'evento
33
     *
34
     * @var array
35
     */
36
    private $properties;
37
38
    /**
39
     * costruttore
40
     */
41
    final public function __construct($aggregateId, array $properties = null)
0 ignored issues
show
Coding Style introduced by
Unnecessary FINAL modifier in FINAL class
Loading history...
42
    {
43
        // autoinizialize
44
        $this->special = 10;
45
        // autoinizialize
46
        $this->occurredOn = new \DateTime();
47
        $this->aggregateId = $aggregateId;
48
        $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...
49
    }
50
51
    /**
52
     * @return int
53
     */
54
    final public function getSpecial()
0 ignored issues
show
Coding Style introduced by
Unnecessary FINAL modifier in FINAL class
Loading history...
55
    {
56
        return $this->special;
57
    }
58
59
    /**
60
     * @var special int
61
     */
62
    final public function setSpecial(int $special)
0 ignored issues
show
Coding Style introduced by
Unnecessary FINAL modifier in FINAL class
Loading history...
63
    {
64
        $this->special = $special;
65
    }
66
67
    /**
68
     * @return \DateTime
69
     */
70
    final public function getOccurredOn()
0 ignored issues
show
Coding Style introduced by
Unnecessary FINAL modifier in FINAL class
Loading history...
71
    {
72
        return $this->occurredOn;
73
    }
74
75
    /**
76
     * @return int
77
     */
78
    final public function getAggregateId()
0 ignored issues
show
Coding Style introduced by
Unnecessary FINAL modifier in FINAL class
Loading history...
79
    {
80
        return $this->aggregateId;
81
    }
82
83
    /**
84
     * @return array
85
     */
86
    final public function getProperties()
0 ignored issues
show
Coding Style introduced by
Unnecessary FINAL modifier in FINAL class
Loading history...
87
    {
88
        return $this->properties;
89
    }
90
}
91