Completed
Pull Request — master (#27)
by Yuichi
05:39 queued 04:15
created

Comments   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 23.08%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
lcom 1
cbo 4
dl 0
loc 42
ccs 3
cts 13
cp 0.2308
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A get() 0 17 1
1
<?php
2
3
namespace CybozuHttp\Api\Kintone;
4
5
use CybozuHttp\Client;
6
use CybozuHttp\Api\KintoneApi;
7
use CybozuHttp\Middleware\JsonStream;
8
9
/**
10
 * @author ochi51 <[email protected]>
11
 */
12
class Comments
13
{
14
    /**
15
     * @var Client
16
     */
17
    private $client;
18
19 1
    public function __construct(Client $client)
20
    {
21 1
        $this->client = $client;
22 1
    }
23
24
    /**
25
     * Get record comments
26
     * https://cybozudev.zendesk.com/hc/ja/articles/208242326
27
     *
28
     * @param int $appId
29
     * @param int $recordId
30
     * @param string $order "asc" or "desc"
31
     * @param int $offset
32
     * @param int $limit Max = 10
33
     * @param int $guestSpaceId
34
     * @return array
35
     */
36
    public function get($appId, $recordId, $order = 'desc', $offset = 0, $limit = 10, $guestSpaceId = null)
37
    {
38
        $options = ['json' => [
39
            'app' => $appId,
40
            'record' => $recordId,
41
            'order' => $order,
42
            'offset' => $offset,
43
            'limit' => $limit
44
        ]];
45
46
        /** @var JsonStream $stream */
47
        $stream = $this->client
48
            ->get(KintoneApi::generateUrl('record/comments.json', $guestSpaceId), $options)
49
            ->getBody();
50
51
        return $stream->jsonSerialize()['comments'];
52
    }
53
}