inspirum /
balikobot-php
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace Inspirum\Balikobot\Model\Status; |
||
| 6 | |||
| 7 | use DateTimeInterface; |
||
| 8 | use Inspirum\Arrayable\BaseModel; |
||
| 9 | |||
| 10 | /** |
||
| 11 | * @extends \Inspirum\Arrayable\BaseModel<string,mixed> |
||
| 12 | */ |
||
| 13 | final class DefaultStatus extends BaseModel implements Status |
||
| 14 | { |
||
| 15 | 20 | public function __construct( |
|
| 16 | private readonly string $carrier, |
||
| 17 | private readonly string $carrierId, |
||
| 18 | private readonly float $id, |
||
| 19 | private readonly string $name, |
||
| 20 | private readonly string $description, |
||
| 21 | private readonly string $type, |
||
| 22 | private readonly ?DateTimeInterface $date, |
||
| 23 | ) { |
||
| 24 | 20 | } |
|
| 25 | |||
| 26 | 15 | public function getCarrier(): string |
|
| 27 | { |
||
| 28 | 15 | return $this->carrier; |
|
| 29 | } |
||
| 30 | |||
| 31 | 8 | public function getCarrierId(): string |
|
| 32 | { |
||
| 33 | 8 | return $this->carrierId; |
|
| 34 | } |
||
| 35 | |||
| 36 | 1 | public function getId(): float |
|
| 37 | { |
||
| 38 | 1 | return $this->id; |
|
| 39 | } |
||
| 40 | |||
| 41 | 1 | public function getName(): string |
|
| 42 | { |
||
| 43 | 1 | return $this->name; |
|
| 44 | } |
||
| 45 | |||
| 46 | 1 | public function getDescription(): string |
|
| 47 | { |
||
| 48 | 1 | return $this->description; |
|
| 49 | } |
||
| 50 | |||
| 51 | 1 | public function getType(): string |
|
| 52 | { |
||
| 53 | 1 | return $this->type; |
|
| 54 | } |
||
| 55 | |||
| 56 | 1 | public function getDate(): ?DateTimeInterface |
|
| 57 | { |
||
| 58 | 1 | return $this->date; |
|
| 59 | } |
||
| 60 | |||
| 61 | /** @inheritDoc */ |
||
| 62 | 2 | public function __toArray(): array |
|
| 63 | { |
||
| 64 | 2 | return [ |
|
|
0 ignored issues
–
show
|
|||
| 65 | 2 | 'carrier' => $this->carrier, |
|
| 66 | 2 | 'carrierId' => $this->carrierId, |
|
| 67 | 2 | 'id' => $this->id, |
|
| 68 | 2 | 'name' => $this->name, |
|
| 69 | 2 | 'description' => $this->description, |
|
| 70 | 2 | 'type' => $this->type, |
|
| 71 | 2 | 'date' => $this->date?->format(DateTimeInterface::ATOM), |
|
| 72 | 2 | ]; |
|
| 73 | } |
||
| 74 | } |
||
| 75 |
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: