SessioneCampo::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 4
1
<?php
2
3
namespace BitPrepared\Bundle\FormazioneBundle\Domain\Entity;
4
5
use BitPrepared\Bundle\FormazioneBundle\Domain\ValueObject\Sessione;
6
use BitPrepared\Bundle\FormazioneBundle\Domain\ValueObject\TipologiaCampo;
7
8
/**
9
 * No comment found on ddd model
10
 */
11
final class SessioneCampo
12
{
13
    use SessioneCampoTrait;
14
15
    /**
16
     * identificativo univoco della sessione
17
     *
18
     * @var int
19
     */
20
    private $id;
21
22
    /**
23
     * Sessione generica utilizzabile in un campo
24
     *
25
     * @var BitPrepared\Bundle\FormazioneBundle\Domain\ValueObject\Sessione
26
     */
27
    private $sessione;
28
29
    /**
30
     * Tipologia di campo CFM/CFT/CCG/CAM
31
     *
32
     * @var BitPrepared\Bundle\FormazioneBundle\Domain\ValueObject\TipologiaCampo
33
     */
34
    private $tipologiaCampo;
35
36
    /**
37
     * Documenti correlati alla sessione al campo
38
     *
39
     * @var array
40
     */
41
    private $documentiCorrelati;
42
43
    /**
44
     * costruttore
45
     */
46
    final public function __construct($id, Sessione $sessione = null, TipologiaCampo $tipologiaCampo = null, array $documentiCorrelati = null)
0 ignored issues
show
Coding Style introduced by
Unnecessary FINAL modifier in FINAL class
Loading history...
47
    {
48
        $this->id = $id;
49
        $this->sessione = $sessione;
50
        $this->tipologiaCampo = $tipologiaCampo;
0 ignored issues
show
Documentation Bug introduced by
It seems like $tipologiaCampo can also be of type object<BitPrepared\Bundl...eObject\TipologiaCampo>. However, the property $tipologiaCampo is declared as type object<BitPrepared\Bundl...eObject\TipologiaCampo>. 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...
51
        $this->documentiCorrelati = $documentiCorrelati;
0 ignored issues
show
Documentation Bug introduced by
It seems like $documentiCorrelati can be null. However, the property $documentiCorrelati 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...
52
    }
53
54
    /**
55
     * @return int
56
     */
57
    final public function getId()
0 ignored issues
show
Coding Style introduced by
Unnecessary FINAL modifier in FINAL class
Loading history...
58
    {
59
        return $this->id;
60
    }
61
62
    /**
63
     * @return BitPrepared\Bundle\FormazioneBundle\Domain\ValueObject\Sessione
64
     */
65
    final public function getSessione()
0 ignored issues
show
Coding Style introduced by
Unnecessary FINAL modifier in FINAL class
Loading history...
66
    {
67
        return $this->sessione;
68
    }
69
70
    /**
71
     * @return BitPrepared\Bundle\FormazioneBundle\Domain\ValueObject\TipologiaCampo
72
     */
73
    final public function getTipologiaCampo()
0 ignored issues
show
Coding Style introduced by
Unnecessary FINAL modifier in FINAL class
Loading history...
74
    {
75
        return $this->tipologiaCampo;
76
    }
77
78
    /**
79
     * @return array
80
     */
81
    final public function getDocumentiCorrelati()
0 ignored issues
show
Coding Style introduced by
Unnecessary FINAL modifier in FINAL class
Loading history...
82
    {
83
        return $this->documentiCorrelati;
84
    }
85
}
86