Department::delete()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 8
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 8
loc 8
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace EntWeChat\User;
4
5
use EntWeChat\Core\AbstractAPI;
6
7
/**
8
 * Class Department.
9
 */
10
class Department extends AbstractAPI
11
{
12
    const API_GET = 'https://qyapi.weixin.qq.com/cgi-bin/department/list';
13
    const API_CREATE = 'https://qyapi.weixin.qq.com/cgi-bin/department/create';
14
    const API_UPDATE = 'https://qyapi.weixin.qq.com/cgi-bin/department/update';
15
    const API_DELETE = 'https://qyapi.weixin.qq.com/cgi-bin/department/delete';
16
17
    /**
18
     * Create Department.
19
     *
20
     * @param string   $name
21
     * @param int      $parentId
22
     * @param int|null $order
23
     * @param int|null $partyId
24
     *
25
     * @return int
26
     */
27
    public function create($name, $parentId, $order = null, $partyId = null)
28
    {
29
        $params = [
30
            'name'     => $name,
31
            'parentid' => $parentId,
32
            'order'    => $order,
33
            'id'       => $partyId,
34
        ];
35
36
        return $this->parseJSON('json', [self::API_CREATE, $params]);
37
    }
38
39
    /**
40
     * List all Departments.
41
     *
42
     * @return array
43
     */
44 View Code Duplication
    public function lists($partyId = null)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
45
    {
46
        $params = [
47
            'id' => $partyId,
48
        ];
49
50
        return $this->parseJSON('get', [self::API_GET, $params]);
51
    }
52
53
    /**
54
     * Update a Department.
55
     *
56
     * @param int   $partyId
57
     * @param array $name
0 ignored issues
show
Bug introduced by
There is no parameter named $name. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
58
     *
59
     * @return bool
60
     */
61
    public function update($partyId, array $partyInfo = [])
62
    {
63
        $params = array_merge($partyInfo, ['id' => $partyId]);
64
65
        return $this->parseJSON('json', [self::API_UPDATE, $params]);
66
    }
67
68
    /**
69
     * Delete Department.
70
     *
71
     * @param int $groupId
0 ignored issues
show
Bug introduced by
There is no parameter named $groupId. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
72
     *
73
     * @return bool
74
     */
75 View Code Duplication
    public function delete($partyId)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
76
    {
77
        $params = [
78
            'id' => $partyId,
79
        ];
80
81
        return $this->parseJSON('json', [self::API_DELETE, $params]);
82
    }
83
}
84