MonetaryAccountResource::getMonetaryAccount()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 6
Ratio 100 %

Importance

Changes 0
Metric Value
dl 6
loc 6
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
3
namespace Bunq\Resource;
4
5
use Bunq\BunqClient;
6
7 View Code Duplication
final class MonetaryAccountResource
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
8
{
9
    /**
10
     * @var BunqClient
11
     */
12
    private $client;
13
14
    /**
15
     * @param BunqClient $client
16
     */
17
    public function __construct(BunqClient $client)
18
    {
19
        $this->client = $client;
20
    }
21
22
    /**
23
     * Lists all the Monetary accounts for the current user.
24
     *
25
     * @param integer $userId
26
     *
27
     * @return array
28
     */
29
    public function listMonetaryAccounts($userId)
30
    {
31
        $monetaryAccounts = $this->client->get($this->getResourceEndpoint($userId));
32
33
        return $monetaryAccounts;
34
    }
35
36
    /**
37
     * Gets a Monetary Account by its identifier.
38
     *
39
     * @param integer $userId
40
     * @param integer $id
41
     *
42
     * @return array
43
     */
44
    public function getMonetaryAccount($userId, $id)
45
    {
46
        $monetaryAccount = $this->client->get($this->getResourceEndpoint($userId) . '/' . (int)$id);
47
48
        return $monetaryAccount['Response'][0]['MonetaryAccountBank'];
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54
    private function getResourceEndpoint($userId)
55
    {
56
        return '/v1/user/' . (int) $userId . '/monetary-account';
57
    }
58
}
59