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.

Employee::promote()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
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;
14
15
use Al\ResourceManagement\Domain\Event\EmployeeFired;
16
use Al\ResourceManagement\Domain\Event\EmployeeHired;
17
use Al\ResourceManagement\Domain\Event\EmployeePromoted;
18
use Ramsey\Uuid\Uuid;
19
use Ramsey\Uuid\UuidInterface;
20
use SimpleBus\Message\Recorder\ContainsRecordedMessages;
21
use SimpleBus\Message\Recorder\PrivateMessageRecorderCapabilities;
22
23
final class Employee implements EmployeeInterface, ContainsRecordedMessages
24
{
25
    use PrivateMessageRecorderCapabilities;
26
27
    /** @var Uuid */
28
    private $id;
29
30
    /** @var string */
31
    private $name;
32
33
    /** @var string */
34
    private $position;
35
36
    /** @var int */
37
    private $salaryScale;
38
39
    /** @var \DateTimeInterface */
40
    private $firedAt;
41
42
    private function __construct(
43
        UuidInterface $identifier,
44
        string $name,
45
        string $forPosition,
46
        int $withSalaryScale,
47
        \DateTimeInterface $hiredAt
48
    ) {
49
        $this->id = $identifier;
50
        $this->name = $name;
51
        $this->position = $forPosition;
52
        $this->salaryScale = $withSalaryScale;
53
        $this->hiredAt = $hiredAt;
0 ignored issues
show
Bug introduced by
The property hiredAt does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
54
        $this->firedAt = null;
55
56
        $this->record(new EmployeeHired((string)$this->id, $this->name, $this->position));
57
    }
58
59
    /**
60
     * {@inheritdoc}
61
     */
62
    public static function hire(
63
        UuidInterface $identifier,
64
        string $name,
65
        string $forPosition,
66
        int $withSalaryScale,
67
        \DateTimeInterface $hiredAt
68
    ) {
69
        return new self($identifier, $name, $forPosition, $withSalaryScale, $hiredAt);
70
    }
71
72
    /**
73
     * {@inheritdoc}
74
     */
75
    public function promote(string $toNewPosition, int $withNewSalaryScale)
76
    {
77
        $this->position = $toNewPosition;
78
        $this->salaryScale = $withNewSalaryScale;
79
80
        $this->record(new EmployeePromoted((string)$this->id, $this->name, $this->position));
81
    }
82
83
    /**
84
     * {@inheritdoc}
85
     */
86
    public function fire(\DateTime $firedAt)
87
    {
88
        $this->firedAt = $firedAt;
89
90
        $this->record(new EmployeeFired((string)$this->id, $this->name, $this->position));
91
    }
92
}
93