Boards   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 112
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 8
lcom 2
cbo 4
dl 0
loc 112
ccs 19
cts 19
cp 1
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A all() 0 4 1
A filter() 0 7 1
A invitedTo() 0 4 1
A invitedToField() 0 6 1
A pin() 0 4 1
A unpin() 0 4 1
A backgrounds() 0 4 1
A stars() 0 4 1
1
<?php
2
3
namespace Trello\Api\Member;
4
5
use Trello\Api\AbstractApi;
6
use Trello\Api\Board;
7
use Trello\Api\Member\Board\Backgrounds;
8
use Trello\Api\Member\Board\Stars;
9
use Trello\Exception\InvalidArgumentException;
10
11
/**
12
 * Trello Member Boards API
13
 * @link https://trello.com/docs/api/member
14
 *
15
 * Fully implemented.
16
 */
17
class Boards extends AbstractApi
18
{
19
    protected $path = 'members/#id#/boards';
20
21
    /**
22
     * Get boads related to a given member
23
     * @link https://trello.com/docs/api/member/#get-1-members-idmember-or-username-boards
24
     *
25
     * @param string $id     the member's id or username
26
     * @param array  $params optional parameters
27
     *
28
     * @return array
29
     */
30 1
    public function all($id = "me", array $params = array())
31
    {
32 1
        return $this->get($this->getPath($id), $params);
33
    }
34
35
    /**
36
     * Filter boards related to a given member
37
     * @link https://trello.com/docs/api/member/#get-1-members-idmember-or-username-boards-filter
38
     *
39
     * @param string       $id     the board's id
40
     * @param string|array $filter array of / one of 'all', none', 'open', 'closed', 'all'
41
     *
42
     * @return array
43
     */
44 3
    public function filter($id, $filter = 'all')
45
    {
46 3
        $allowed = array('all', 'members', 'organization', 'public', 'open', 'closed', 'pinned', 'unpinned', 'starred');
47 3
        $filters = $this->validateAllowedParameters($allowed, $filter, 'filter');
48
49 3
        return $this->get($this->getPath($id).'/'.implode(',', $filters));
50
    }
51
52
    /**
53
     * Get boads a given member is invited to
54
     * @link https://trello.com/docs/api/member/#get-1-members-idmember-or-username-boardsinvited
55
     *
56
     * @param string $id     the member's id or username
57
     * @param array  $params optional parameters
58
     *
59
     * @return array
60
     */
61 1
    public function invitedTo($id, array $params = array())
62
    {
63 1
        return $this->get($this->getPath($id).'Invited', $params);
64
    }
65
66
    /**
67
     * Get a field of a boad a given member is invited to
68
     * @link https://trello.com/docs/api/member/#get-1-members-idmember-or-username-boardsinvited-field
69
     *
70
     * @param string $id     the member's id or username
71
     *
72
     * @return array
73
     */
74 2
    public function invitedToField($id, $field)
75
    {
76 2
        $this->validateAllowedParameters(Board::$fields, $field, 'field');
77
78 1
        return $this->get($this->getPath($id).'Invited/'.rawurlencode($field));
79
    }
80
81
    /**
82
     * Pin a boad for a given member
83
     * @link https://trello.com/docs/api/member/#post-1-members-idmember-or-username-idboardspinned
84
     *
85
     * @param string $id      the member's id or username
86
     * @param string $boardId the board's id
87
     *
88
     * @return array
89
     */
90 1
    public function pin($id, $boardId)
91
    {
92 1
        return $this->post('members/'.rawurlencode($id).'/idBoardsPinned', array('value' => $boardId));
93
    }
94
95
    /**
96
     * Unpin a boad for a given member
97
     * @link https://trello.com/docs/api/member/#delete-1-members-idmember-or-username-idboardspinned-idboard
98
     *
99
     * @param string $id      the member's id or username
100
     * @param string $boardId the board's id
101
     *
102
     * @return array
103
     */
104 1
    public function unpin($id, $boardId)
105
    {
106 1
        return $this->delete('members/'.rawurlencode($id).'/idBoardsPinned/'.rawurlencode($boardId));
107
    }
108
109
    /**
110
     * Board Backgrounds API
111
     *
112
     * @return Backgrounds
113
     */
114 2
    public function backgrounds()
115
    {
116 2
        return new Backgrounds($this->client);
117
    }
118
119
    /**
120
     * Board Stars API
121
     *
122
     * @return Stars
123
     */
124 2
    public function stars()
125
    {
126 2
        return new Stars($this->client);
127
    }
128
}
129