NewSessioneRequest::getTipoCampo()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace BitPrepared\Bundle\FormazioneBundle\Domain\Service\CommandRequest;
4
5
use BitPrepared\Bundle\FormazioneBundle\Domain\Service\Request;
6
use BitPrepared\Bundle\FormazioneBundle\Domain\ValueObject\TipologiaCampo;
7
8
/**
9
 * No comment found on ddd model
10
 */
11
final class NewSessioneRequest extends Request
12
{
13
    /**
14
     * titolo della sessione
15
     *
16
     * @var string
17
     */
18
    private $title;
19
20
    /**
21
     * descrizione della sessione
22
     *
23
     * @var string
24
     */
25
    private $description;
26
27
    /**
28
     * Tipologia di campo CFM/CFT/CCG/CAM
29
     *
30
     * @var BitPrepared\Bundle\FormazioneBundle\Domain\ValueObject\TipologiaCampo
31
     */
32
    private $tipoCampo;
33
34
    /**
35
     * costruttore
36
     */
37
    final public function __construct($title, $description = null, TipologiaCampo $tipoCampo = null)
0 ignored issues
show
Coding Style introduced by
Unnecessary FINAL modifier in FINAL class
Loading history...
38
    {
39
        $this->title = $title;
40
        $this->description = $description;
41
        $this->tipoCampo = $tipoCampo;
0 ignored issues
show
Documentation Bug introduced by
It seems like $tipoCampo can also be of type object<BitPrepared\Bundl...eObject\TipologiaCampo>. However, the property $tipoCampo 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...
42
    }
43
44
    /**
45
     * @return string
46
     */
47
    final public function getTitle()
0 ignored issues
show
Coding Style introduced by
Unnecessary FINAL modifier in FINAL class
Loading history...
48
    {
49
        return $this->title;
50
    }
51
52
    /**
53
     * @return string
54
     */
55
    final public function getDescription()
0 ignored issues
show
Coding Style introduced by
Unnecessary FINAL modifier in FINAL class
Loading history...
56
    {
57
        return $this->description;
58
    }
59
60
    /**
61
     * @return BitPrepared\Bundle\FormazioneBundle\Domain\ValueObject\TipologiaCampo
62
     */
63
    final public function getTipoCampo()
0 ignored issues
show
Coding Style introduced by
Unnecessary FINAL modifier in FINAL class
Loading history...
64
    {
65
        return $this->tipoCampo;
66
    }
67
}
68