1 | <?php |
||
2 | declare(strict_types=1); |
||
3 | |||
4 | namespace Fns; |
||
5 | |||
6 | class Product |
||
7 | { |
||
8 | public function __construct(array $item) |
||
9 | { |
||
10 | foreach ($item as $property => $value) { |
||
11 | $this->{$property} = $value; |
||
12 | } |
||
13 | } |
||
14 | |||
15 | public function getName() : string |
||
16 | { |
||
17 | return $this->name; |
||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
18 | } |
||
19 | |||
20 | public function getPrice():int |
||
21 | { |
||
22 | return (int)$this->price; |
||
0 ignored issues
–
show
|
|||
23 | } |
||
24 | |||
25 | public function getQuantity() : int |
||
26 | { |
||
27 | return (int)$this->quantity; |
||
0 ignored issues
–
show
|
|||
28 | } |
||
29 | |||
30 | public function getCost() : int |
||
31 | { |
||
32 | return (int)$this->sum; |
||
0 ignored issues
–
show
|
|||
33 | } |
||
34 | } |
||
35 |