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