Pot::withdraw()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
c 0
b 0
f 0
rs 10
cc 1
eloc 1
nc 1
nop 2
1
<?php
2
3
namespace Amelia\Monzo\Models;
4
5
/**
6
 * A savings pot.
7
 *
8
 * @property string $id              The ID of this Pot.
9
 * @property string $name            The name of this pot.
10
 * @property int $balance            The amount in this pot.
11
 * @property string $currency        The currency of this pot, e.g. GBP.
12
 * @property string $style           The style of this pot, e.g. "raspberry".
13
 * @property \Carbon\Carbon $created The date this pot was created.
14
 * @property \Carbon\Carbon $updated The date this pot was last updated.
15
 * @property bool $deleted           If this pot has been deleted.
16
 */
17
class Pot extends Model
18
{
19
    /**
20
     * An array of costs for this model.
21
     *
22
     * @var array
23
     */
24
    protected $casts = [
25
        'created' => 'date',
26
        'updated' => 'date',
27
    ];
28
29
    /**
30
     * Add a given amount to a pot.
31
     *
32
     * @param int $amount
33
     * @param string|null $account
34
     * @return \Amelia\Monzo\Models\Pot
35
     */
36
    public function deposit(int $amount, string $account = null)
37
    {
38
        return $this->monzo->addToPot($this->id, $amount, $account);
39
    }
40
41
    /**
42
     * Add a given amount to a pot.
43
     *
44
     * @param int $amount
45
     * @param string|null $account
46
     * @return \Amelia\Monzo\Models\Pot
47
     */
48
    public function withdraw(int $amount, string $account = null)
49
    {
50
        return $this->monzo->withdrawFromPot($this->id, $amount, $account);
51
    }
52
53
    /**
54
     * Update a pot.
55
     *
56
     * @param array $attributes
57
     * @return \Amelia\Monzo\Models\Pot
58
     */
59
    public function update(array $attributes)
60
    {
61
        return $this->monzo->updatePot($this->id, $attributes);
62
    }
63
}
64