Passed
Push — feature/unit-tests ( 669eab...c8ab0b )
by Yuichi
12:06 queued 01:13
created

OrganizationUsers   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 37
ccs 12
cts 12
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 14 1
A __construct() 0 3 1
1
<?php
2
3
namespace CybozuHttp\Api\User;
4
5
use CybozuHttp\Client;
6
use CybozuHttp\Api\UserApi;
7
use CybozuHttp\Middleware\JsonStream;
8
9
/**
10
 * @author ochi51 <[email protected]>
11
 */
12
class OrganizationUsers
13
{
14
    public const MAX_GET_USERS = 100;
15
16
    /**
17
     * @var Client
18
     */
19
    private $client;
20
21 1
    public function __construct(Client $client)
22
    {
23 1
        $this->client = $client;
24
    }
25
26
    /**
27
     * Get users and titles of organization
28
     * https://cybozudev.zendesk.com/hc/ja/articles/202124774#step2
29
     *
30
     * @param string $code
31
     * @param int $offset
32
     * @param int $limit
33
     * @return array
34
     */
35 1
    public function get($code, $offset = 0, $limit = self::MAX_GET_USERS): array
36
    {
37 1
        $options = ['json' => [
38 1
            'code' => $code,
39 1
            'offset' => $offset,
40 1
            'size' => $limit
41 1
        ]];
42
43
        /** @var JsonStream $stream */
44 1
        $stream = $this->client
45 1
            ->get(UserApi::generateUrl('organization/users.json'), $options)
46 1
            ->getBody();
47
48 1
        return $stream->jsonSerialize()['userTitles'];
49
    }
50
}
51