Passed
Pull Request — master (#9)
by Бабичев
03:04
created

Item::getAmountProduct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
nc 1
nop 0
dl 0
loc 3
c 0
b 0
f 0
cc 1
rs 10
1
<?php
2
3
namespace Bavix\Wallet\Test\Models;
4
5
use Bavix\Wallet\Interfaces\Customer;
6
use Bavix\Wallet\Interfaces\Product;
7
use Bavix\Wallet\Traits\HasWallet;
8
use Illuminate\Database\Eloquent\Model;
9
10
/**
11
 * Class Item
12
 *
13
 * @package Bavix\Wallet\Test\Models
14
 * @property string $name
15
 * @property int $quantity
16
 * @property int $price
17
 */
18
class Item extends Model implements Product
19
{
20
21
    use HasWallet;
0 ignored issues
show
Bug introduced by
The trait Bavix\Wallet\Traits\HasWallet requires the property $total which is not provided by Bavix\Wallet\Test\Models\Item.
Loading history...
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
50
    {
51
        return null;
52
    }
53
54
}
55