Total Complexity | 6 |
Total Lines | 72 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
13 | class CollectionShow2 extends Model |
||
14 | { |
||
15 | /** @var int */ |
||
16 | protected $id; |
||
17 | |||
18 | /** @var string */ |
||
19 | protected $title; |
||
20 | |||
21 | /** @var string */ |
||
22 | protected $description; |
||
23 | |||
24 | /** @var float */ |
||
25 | protected $price; |
||
26 | |||
27 | /** |
||
28 | * parse |
||
29 | * |
||
30 | * @param array $data |
||
31 | */ |
||
32 | public function parse(array $data) |
||
33 | { |
||
34 | $this->id = (int)$data['id']; |
||
35 | $this->title = (string)$data['Title']; |
||
36 | $this->description = (string)$data['Description']; |
||
37 | $this->price = (string)$data['Price']; |
||
|
|||
38 | } |
||
39 | |||
40 | /** |
||
41 | * toArray |
||
42 | * |
||
43 | * @return array |
||
44 | */ |
||
45 | public function toArray(): array |
||
46 | { |
||
47 | return [ |
||
48 | 'id' => $this->id, |
||
49 | 'Title' => $this->title, |
||
50 | 'Description' => $this->description, |
||
51 | 'Price' => $this->price, |
||
52 | ]; |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * @return int |
||
57 | */ |
||
58 | public function getId(): int |
||
61 | } |
||
62 | |||
63 | /** |
||
64 | * @return string |
||
65 | */ |
||
66 | public function getTitle(): string |
||
67 | { |
||
68 | return $this->title; |
||
69 | } |
||
70 | |||
71 | /** |
||
72 | * @return string |
||
73 | */ |
||
74 | public function getDescription(): string |
||
75 | { |
||
76 | return $this->description; |
||
77 | } |
||
78 | |||
79 | /** |
||
80 | * @return float |
||
81 | */ |
||
82 | public function getPrice(): float |
||
85 | } |
||
86 | |||
87 | } |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.