Members   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 94
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 2
dl 0
loc 94
ccs 17
cts 17
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A all() 0 4 1
A add() 0 4 1
A set() 0 10 2
A remove() 0 4 1
A addVote() 0 4 1
A removeVote() 0 4 1
1
<?php
2
3
namespace Trello\Api\Card;
4
5
use Trello\Api\AbstractApi;
6
use Trello\Exception\InvalidArgumentException;
7
8
/**
9
 * Trello Card Members API
10
 * @link https://trello.com/docs/api/card
11
 *
12
 * Fully implemented.
13
 */
14
class Members extends AbstractApi
15
{
16
    protected $path = 'cards/#id#/members';
17
18
    /**
19
     * Get members related to a given card
20
     * @link https://trello.com/docs/api/card/#get-1-cards-card-id-or-shortlink-members
21
     *
22
     * @param string $id     the card's id or short link
23
     * @param array  $params optional parameters
24
     *
25
     * @return array
26
     */
27 1
    public function all($id, array $params = array())
28
    {
29 1
        return $this->get($this->getPath($id), $params);
30
    }
31
32
    /**
33
     * Set members of a given card
34
     * @link https://trello.com/docs/api/card/#put-1-cards-card-id-or-shortlink-idmembers
35
     *
36
     * @param string $id      the card's id or short link
37
     * @param array  $members An array of member ids
38
     *
39
     * @return array
40
     */
41 2
    public function set($id, array $members)
42
    {
43 2
        if (!count($members)) {
44 1
            throw new InvalidArgumentException('You must specify at least one member id.');
45
        }
46
47 1
        $members = implode(',', $members);
48
49 1
        return $this->put($this->getPath($id), array('value' => $members));
50 1
    }
51
52
    /**
53
     * Add a member to a given card
54
     * @link https://trello.com/docs/api/card/#post-1-cards-card-id-or-shortlink-idmembers
55
     *
56
     * @param string $id       the card's id or short link
57
     * @param array  $memberId the member's id
58
     *
59
     * @return array
60
     */
61
    public function add($id, $memberId)
62 1
    {
63
        return $this->post($this->getPath($id), array('value' => $memberId));
64 1
    }
65 1
66
    /**
67
     * Remove a given member from a given card
68
     * @link https://trello.com/docs/api/card/#delete-1-cards-card-id-or-shortlink-idmembers-idmember
69
     *
70
     * @param string $id       the card's id or short link
71
     * @param string $memberId the members's id
72
     *
73
     * @return array
74
     */
75
    public function remove($id, $memberId)
76
    {
77 1
        return $this->delete($this->getPath($id).'/'.rawurlencode($memberId));
78
    }
79 1
80
    /**
81
     * Add a given member's vote to a given card
82
     * @link https://trello.com/docs/api/card/#post-1-cards-card-id-or-shortlink-membersvoted
83
     *
84
     * @param string $id       the card's id or short link
85
     * @param string $memberId the members's id
86
     *
87
     * @return array
88
     */
89
    public function addVote($id, $memberId)
90
    {
91 1
        return $this->post($this->getPath($id).'/membersVoted', array('value' => $memberId));
92
    }
93 1
94
    /**
95
     * Remove a given member's vote from a given card
96
     * @link https://trello.com/docs/api/card/#delete-1-cards-card-id-or-shortlink-membersvoted-idmember
97
     *
98
     * @param string $id       the card's id or short link
99
     * @param string $memberId the members's id
100
     *
101
     * @return array
102
     */
103
    public function removeVote($id, $memberId)
104
    {
105 1
        return $this->delete($this->getPath($id).'/membersVoted/'.rawurlencode($memberId));
106
    }
107
}
108