Completed
Push — master ( 32a55a...fb9711 )
by Mitchel
02:18
created

UserResource::listUsers()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Bunq\Resource;
4
5
use Bunq\BunqClient;
6
7
final class UserResource
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 users within the current session.
24
     *
25
     * @return array
26
     */
27
    public function listUsers()
28
    {
29
        return $this->client->get($this->getResourceEndpoint());
30
    }
31
32
    /**
33
     * Gets a user its information.
34
     *
35
     * @param integer $id
36
     *
37
     * @return array
38
     */
39
    public function getUser($id)
40
    {
41
        $response = $this->client->get($this->getResourceEndpoint() . '/' . (int)$id);
42
43
        return $response['Response'][0]['UserCompany'];
44
    }
45
46
    /**
47
     * @return string
48
     */
49
    private function getResourceEndpoint()
50
    {
51
        return '/v1/user';
52
    }
53
}
54