GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

EmployeeList::getName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
declare(strict_types=1);
3
4
/*
5
 * This file is part of the AL labs package
6
 *
7
 * (c) Arnaud Langlade
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
namespace Al\ResourceManagement\Domain\ReadModel;
14
15
final class EmployeeList
16
{
17
    /** @var string */
18
    private $id;
19
20
    /** @var string */
21
    private $name;
22
23
    /** @var string */
24
    private $position;
25
26
    /** @var int */
27
    private $salaryScale;
28
29
    /** @var string */
30
    private $firedAt;
31
32
    public function __construct(
33
        string $id,
34
        string $name,
35
        string $position,
36
        int $salaryScale,
37
        \DateTimeInterface $firedAt = null
38
    ) {
39
        $this->id = $id;
40
        $this->name = $name;
41
        $this->position = $position;
42
        $this->salaryScale = $salaryScale;
43
        $this->firedAt = $firedAt;
0 ignored issues
show
Documentation Bug introduced by
It seems like $firedAt can also be of type object<DateTimeInterface>. However, the property $firedAt 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...
44
    }
45
46
    /**
47
     * @return string
48
     */
49
    public function getId(): string
50
    {
51
        return $this->id;
52
    }
53
54
    /**
55
     * @return string
56
     */
57
    public function getName(): string
58
    {
59
        return $this->name;
60
    }
61
62
    /**
63
     * @return string
64
     */
65
    public function getPosition(): string
66
    {
67
        return $this->position;
68
    }
69
70
    /**
71
     * @return int
72
     */
73
    public function getSalaryScale(): int
74
    {
75
        return $this->salaryScale;
76
    }
77
78
    /**
79
     * @return string
80
     */
81
    public function getFiredAt(): string
82
    {
83
        return $this->firedAt->format('Y-m-d');
0 ignored issues
show
Bug introduced by
The method format cannot be called on $this->firedAt (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
84
    }
85
}
86