1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace Inspirum\Balikobot\Model\Changelog; |
||
6 | |||
7 | use DateTimeInterface; |
||
8 | use Inspirum\Arrayable\BaseModel; |
||
9 | |||
10 | /** |
||
11 | * @extends \Inspirum\Arrayable\BaseModel<string,mixed> |
||
12 | */ |
||
13 | final class DefaultChangelog extends BaseModel implements Changelog |
||
14 | { |
||
15 | 5 | public function __construct( |
|
16 | private readonly string $version, |
||
17 | private readonly DateTimeInterface $date, |
||
18 | private readonly ChangelogStatusCollection $changes, |
||
19 | ) { |
||
20 | 5 | } |
|
21 | |||
22 | 4 | public function getVersion(): string |
|
23 | { |
||
24 | 4 | return $this->version; |
|
25 | } |
||
26 | |||
27 | 1 | public function getDate(): DateTimeInterface |
|
28 | { |
||
29 | 1 | return $this->date; |
|
30 | } |
||
31 | |||
32 | 1 | public function getChanges(): ChangelogStatusCollection |
|
33 | { |
||
34 | 1 | return $this->changes; |
|
35 | } |
||
36 | |||
37 | /** @inheritDoc */ |
||
38 | 2 | public function __toArray(): array |
|
39 | { |
||
40 | 2 | return [ |
|
0 ignored issues
–
show
|
|||
41 | 2 | 'code' => $this->version, |
|
42 | 2 | 'date' => $this->date->format('Y-m-d'), |
|
43 | 2 | 'changes' => $this->changes->__toArray(), |
|
44 | 2 | ]; |
|
45 | } |
||
46 | } |
||
47 |
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: