Completed
Push — master ( 63fe9e...7c1db9 )
by Gerrit
02:35
created

EntityExample   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 53
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 1
A loadRDMMetadata() 0 4 1
A getFaz() 0 4 1
1
<?php
2
/**
3
 * Copyright (C) 2018 Gerrit Addiks.
4
 * This package (including this file) was released under the terms of the GPL-3.0.
5
 * You should have received a copy of the GNU General Public License along with this program.
6
 * If not, see <http://www.gnu.org/licenses/> or send me a mail so i can send you a copy.
7
 * @license GPL-3.0
8
 * @author Gerrit Addiks <[email protected]>
9
 */
10
11
namespace Addiks\RDMBundle\Tests\Hydration;
12
13
use Addiks\RDMBundle\Tests\Hydration\ServiceExample;
14
15
class EntityExample
16
{
17
18
    /**
19
     * @var string
20
     */
21
    public $id;
22
23
    /**
24
     * @var ServiceExample
25
     */
26
    public $foo;
27
28
    /**
29
     * @var ServiceExample
30
     */
31
    public $bar;
32
33
    /**
34
     * @var string
35
     */
36
    public $baz;
37
38
    /**
39
     * @var string
40
     */
41
    private $faz;
42
43
    public function __construct(
44
        ServiceExample $foo = null,
45
        ServiceExample $bar = null,
46
        ServiceExample $baz = null,
47
        ServiceExample $faz = null
48
    ) {
49
        $this->foo = $foo;
50
        $this->bar = $bar;
51
        $this->baz = $baz;
0 ignored issues
show
Documentation Bug introduced by
It seems like $baz can also be of type object<Addiks\RDMBundle\...dration\ServiceExample>. However, the property $baz is declared as type string. 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...
52
        $this->faz = $faz;
0 ignored issues
show
Documentation Bug introduced by
It seems like $faz can also be of type object<Addiks\RDMBundle\...dration\ServiceExample>. However, the property $faz is declared as type string. 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...
53
    }
54
55
    public static $staticMetadata;
56
57
    public static function loadRDMMetadata()
58
    {
59
        return self::$staticMetadata;
60
    }
61
62
    public function getFaz(): ?ServiceExample
63
    {
64
        return $this->faz;
65
    }
66
67
}
68