Client::get()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 2
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of the dingtalk.
4
 * User: Ilham Tahir <[email protected]>
5
 * This source file is subject to the MIT license that is bundled
6
 * with this source code in the file LICENSE.
7
 */
8
9
namespace Aplisin\DingTalk\Department;
10
11
use Aplisin\DingTalk\Kernel\BaseClient;
12
13
class Client extends BaseClient
14
{
15
    /**
16
     * @param int $id
17
     * @return \Aplisin\DingTalk\Kernel\Http\Response
18
     * @throws \GuzzleHttp\Exception\GuzzleException
19
     */
20
    public function listIds($id = 1)
21
    {
22
        return $this->httpGet('/department/list_ids', compact('id'));
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->httpGet('/...st_ids', compact('id')) also could return the type Aplisin\DingTalk\Kernel\Support\Collection|array which is incompatible with the documented return type Aplisin\DingTalk\Kernel\Http\Response.
Loading history...
23
    }
24
25
    /**
26
     * @param int $id
27
     * @param bool $fetchChild
28
     * @param string $lang
29
     * @return \Aplisin\DingTalk\Kernel\Http\Response
30
     * @throws \GuzzleHttp\Exception\GuzzleException
31
     */
32
    public function list($id = 1, $fetchChild = false, $lang = 'zh_CN')
33
    {
34
        $params = [
35
            'id' => $id,
36
            'fetch_child' => $fetchChild,
37
            'lang' => $lang
38
        ];
39
        return $this->httpGet('/department/list', $params);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->httpGet('/...artment/list', $params) also could return the type Aplisin\DingTalk\Kernel\Support\Collection|array which is incompatible with the documented return type Aplisin\DingTalk\Kernel\Http\Response.
Loading history...
40
    }
41
42
    /**
43
     * @param int $id
44
     * @param string $lang
45
     * @return \Aplisin\DingTalk\Kernel\Http\Response
46
     * @throws \GuzzleHttp\Exception\GuzzleException
47
     */
48
    public function get(int $id, $lang = 'zh_CN')
49
    {
50
        $params = [
51
            'id' => $id,
52
            'lang' => $lang
53
        ];
54
        return $this->httpGet('/department/get', $params);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->httpGet('/department/get', $params) also could return the type Aplisin\DingTalk\Kernel\Support\Collection|array which is incompatible with the documented return type Aplisin\DingTalk\Kernel\Http\Response.
Loading history...
55
    }
56
57
    /**
58
     * @param array $data
59
     * @return \Aplisin\DingTalk\Kernel\Http\Response
60
     * @throws \GuzzleHttp\Exception\GuzzleException
61
     */
62
    public function create(array $data)
63
    {
64
        return $this->httpPostJson('/department/create', $data);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->httpPostJs...artment/create', $data) also could return the type Aplisin\DingTalk\Kernel\Support\Collection|array which is incompatible with the documented return type Aplisin\DingTalk\Kernel\Http\Response.
Loading history...
65
    }
66
67
    /**
68
     * @param int $id
69
     * @param array $data
70
     * @return \Aplisin\DingTalk\Kernel\Http\Response
71
     * @throws \GuzzleHttp\Exception\GuzzleException
72
     */
73
    public function update(int $id, array $data)
74
    {
75
        return $this->httpPostJson('/department/update', array_merge(compact('id'), $data));
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->httpPostJs...(compact('id'), $data)) also could return the type Aplisin\DingTalk\Kernel\Support\Collection|array which is incompatible with the documented return type Aplisin\DingTalk\Kernel\Http\Response.
Loading history...
76
    }
77
78
    /**
79
     * @param int $id
80
     * @return \Aplisin\DingTalk\Kernel\Http\Response
81
     * @throws \GuzzleHttp\Exception\GuzzleException
82
     */
83
    public function delete(int $id)
84
    {
85
        return $this->httpGet('/department/delete', compact('id'));
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->httpGet('/...delete', compact('id')) also could return the type Aplisin\DingTalk\Kernel\Support\Collection|array which is incompatible with the documented return type Aplisin\DingTalk\Kernel\Http\Response.
Loading history...
86
    }
87
88
    /**
89
     * @param int $id
90
     * @return \Aplisin\DingTalk\Kernel\Http\Response
91
     * @throws \GuzzleHttp\Exception\GuzzleException
92
     */
93
    public function listPrentDeptsByDept(int $id)
94
    {
95
        return $this->httpGet('/department/list_parent_depts_by_dept', compact('id'));
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->httpGet('/...y_dept', compact('id')) also could return the type Aplisin\DingTalk\Kernel\Support\Collection|array which is incompatible with the documented return type Aplisin\DingTalk\Kernel\Http\Response.
Loading history...
96
    }
97
98
    /**
99
     * @param int $userId
100
     * @return \Aplisin\DingTalk\Kernel\Http\Response
101
     * @throws \GuzzleHttp\Exception\GuzzleException
102
     */
103
    public function listPrentDepts(int $userId)
104
    {
105
        return $this->httpGet('/department/list_parent_depts', compact('userId'));
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->httpGet('/...ts', compact('userId')) also could return the type Aplisin\DingTalk\Kernel\Support\Collection|array which is incompatible with the documented return type Aplisin\DingTalk\Kernel\Http\Response.
Loading history...
106
    }
107
}
108