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

OrganizationUsers::get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 8
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 14
ccs 10
cts 10
cp 1
crap 1
rs 10
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