Total Complexity | 4 |
Total Lines | 34 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
18 | class Item extends Model implements Product |
||
19 | { |
||
20 | |||
21 | use HasWallet; |
||
|
|||
22 | |||
23 | /** |
||
24 | * @var array |
||
25 | */ |
||
26 | protected $fillable = ['name', 'quantity', 'price']; |
||
27 | |||
28 | /** |
||
29 | * @param Customer $customer |
||
30 | * |
||
31 | * @return bool |
||
32 | */ |
||
33 | public function canBuy(Customer $customer): bool |
||
34 | { |
||
35 | return $this->quantity > 0 && !$customer->paid($this); |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * @return int |
||
40 | */ |
||
41 | public function getAmountProduct(): int |
||
42 | { |
||
43 | return $this->price; |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * @return array|null |
||
48 | */ |
||
49 | public function getMetaProduct(): ?array |
||
52 | } |
||
53 | |||
54 | } |
||
55 |