Transactions   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 32
c 0
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A transaction() 0 6 1
A transactions() 0 9 1
1
<?php
2
3
namespace Amelia\Monzo\Api;
4
5
use Amelia\Monzo\Models\Transaction;
6
7
trait Transactions
8
{
9
    /**
10
     * Get a list of transactions for the current user.
11
     *
12
     * @param string|null $account
13
     * @return \Amelia\Monzo\Models\Transaction[]|\Illuminate\Support\Collection
14
     */
15
    public function transactions(string $account = null)
16
    {
17
        $results = $this->expand('merchant')
18
            ->call('GET', 'transactions', [
19
                'account_id' => $account ?? $this->getAccountId(),
20
            ], [], 'transactions', false);
21
22
        return collect($results)->map(function ($item) {
23
            return new Transaction($item, $this);
24
        });
25
    }
26
27
    /**
28
     * Get a single transaction for a given ID.
29
     *
30
     * @param string $id
31
     * @return \Amelia\Monzo\Models\Transaction
32
     */
33
    public function transaction(string $id)
34
    {
35
        $results = $this->expand('merchant')
36
            ->call('GET', "transactions/{$id}", [], [], 'transaction', false);
37
38
        return new Transaction($results, $this);
39
    }
40
}
41