CardResource::getResourceEndpoint()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
dl 4
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Bunq\Resource;
4
5
use Bunq\BunqClient;
6
7 View Code Duplication
final class CardResource
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 cards of the user.
24
     *
25
     * @param integer $userId
26
     *
27
     * @return array
28
     */
29
    public function listCards($userId)
30
    {
31
        return $this->client->get($this->getResourceEndpoint($userId));
32
    }
33
34
    /**
35
     * Gets a user its card information.
36
     *
37
     * @param integer $userId
38
     * @param integer $cardId
39
     *
40
     * @return array
41
     */
42
    public function getCard($userId, $cardId)
43
    {
44
        $card = $this->client->get($this->getResourceEndpoint($userId) . '/' . (int)$cardId);
45
46
        return $card['Response'][0];
47
    }
48
49
    /**
50
     * @param integer $userId
51
     *
52
     * @return string
53
     */
54
    private function getResourceEndpoint($userId)
55
    {
56
        return '/v1/user/' . (int)$userId . '/card';
57
    }
58
}
59