Board   A
last analyzed

Complexity

Total Complexity 23

Size/Duplication

Total Lines 319
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 12

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 23
lcom 2
cbo 12
dl 0
loc 319
ccs 48
cts 48
cp 1
rs 10
c 0
b 0
f 0

23 Methods

Rating   Name   Duplication   Size   Complexity  
A show() 0 4 1
A create() 0 6 1
A update() 0 4 1
A setName() 0 4 1
A setDescription() 0 4 1
A setClosed() 0 4 1
A setSubscribed() 0 4 1
A setOrganization() 0 4 1
A getOrganization() 0 4 1
A getOrganizationField() 0 6 1
A getStars() 0 4 1
A getDeltas() 0 4 1
A setViewed() 0 4 1
A actions() 0 4 1
A lists() 0 4 1
A cards() 0 4 1
A checklists() 0 4 1
A labels() 0 4 1
A members() 0 4 1
A memberships() 0 4 1
A preferences() 0 4 1
A myPreferences() 0 4 1
A powerUps() 0 4 1
1
<?php
2
3
namespace Trello\Api;
4
5
use Trello\Exception\InvalidArgumentException;
6
7
/**
8
 * Trello Board API
9
 * @package PHP Trello API
10
 * @category API
11
 * @link https://trello.com/docs/api/board
12
 *
13
 * Not implemented:
14
 * - Board my preferences API @see Board\MyPreferences
15
 * - Board preferences API @see Board\Preferences
16
 * - Board power ups API @see Board\PowerUps
17
 * - Board memberships API @see Board\Memberships
18
 * - https://trello.com/docs/api/board/#post-1-boards-board-id-calendarkey-generate
19
 * - https://trello.com/docs/api/board/#post-1-boards-board-id-emailkey-generate
20
 */
21
class Board extends AbstractApi
22
{
23
    /**
24
     * Base path of boards api
25
     * @var string
26
     */
27
    protected $path = 'boards';
28
29
    /**
30
     * Board fields
31
     * @link https://trello.com/docs/api/board/#get-1-boards-board-id-field
32
     * @var array
33
     */
34
    public static $fields = array(
35
        'name',
36
        'desc',
37
        'descData',
38
        'closed',
39
        'idOrganization',
40
        'invited',
41
        'pinned',
42
        'starred',
43
        'url',
44
        'prefs',
45
        'invitations',
46
        'memberships',
47
        'shortLink',
48
        'subscribed',
49
        'labelNames',
50
        'powerUps',
51
        'dateLastActivity',
52
        'dateLastView',
53
        'shortUrl',
54
    );
55
56
    /**
57
     * Find a board by id
58
     * @link https://trello.com/docs/api/board/#get-1-boards-board-id
59
     *
60
     * @param string $id     the board's id
61
     * @param array  $params optional attributes
62
     *
63
     * @return array board info
64
     */
65 1
    public function show($id, array $params = array())
66
    {
67 1
        return $this->get($this->getPath().'/'.rawurlencode($id), $params);
68
    }
69
70
    /**
71
     * Create a board
72
     * @link https://trello.com/docs/api/board/#post-1-boards
73
     *
74
     * @param array $params attributes
75
     *
76
     * @return array board info
77
     */
78 2
    public function create(array $params = array())
79
    {
80 2
        $this->validateRequiredParameters(array('name'), $params);
81
82 1
        return $this->post($this->getPath(), $params);
83
    }
84
85
    /**
86
     * Update a board
87
     * @link https://trello.com/docs/api/board/#put-1-boards
88
     *
89
     * @param string $id     the board's id
90
     * @param array  $params board attributes to update
91
     *
92
     * @return array
93
     */
94 1
    public function update($id, array $params = array())
95
    {
96 1
        return $this->put($this->getPath().'/'.rawurlencode($id), $params);
97
    }
98
99
    /**
100
     * Set a given board's name
101
     * @link https://trello.com/docs/api/board/#put-1-boards-board-id-name
102
     *
103
     * @param string $id   the board's id
104
     * @param string $name the name
105
     *
106
     * @return array
107
     */
108 1
    public function setName($id, $name)
109
    {
110 1
        return $this->put($this->getPath().'/'.rawurlencode($id).'/name', array('value' => $name));
111
    }
112
113
    /**
114
     * Set a given board's description
115
     * @link https://trello.com/docs/api/board/#put-1-boards-board-id-desc
116
     *
117
     * @param string $id          the board's id
118
     * @param string $description the description
119
     *
120
     * @return array
121
     */
122 1
    public function setDescription($id, $description)
123
    {
124 1
        return $this->put($this->getPath().'/'.rawurlencode($id).'/desc', array('value' => $description));
125
    }
126
127
    /**
128
     * Set a given board's state
129
     * @link https://trello.com/docs/api/board/#put-1-boards-board-id-closed
130
     *
131
     * @param string $id     the board's id
132
     * @param bool   $closed whether the board should be closed or not
133
     *
134
     * @return array
135
     */
136 1
    public function setClosed($id, $closed = true)
137
    {
138 1
        return $this->put($this->getPath().'/'.rawurlencode($id).'/closed', array('value' => $closed));
139
    }
140
141
    /**
142
     * Set a given board's subscription state
143
     * @link https://trello.com/docs/api/board/#put-1-boards-board-id-subscribed
144
     *
145
     * @param string $id         the board's id
146
     * @param bool   $subscribed whether to subscribe to the board or not
147
     *
148
     * @return array
149
     */
150 1
    public function setSubscribed($id, $subscribed = true)
151
    {
152 1
        return $this->put($this->getPath().'/'.rawurlencode($id).'/subscribed', array('value' => $subscribed));
153
    }
154
155
    /**
156
     * Set a given board's organization
157
     * @link https://trello.com/docs/api/board/#put-1-boards-board-id-organization
158
     *
159
     * @param string $id             the board's id
160
     * @param string $organizationId the organization's id
161
     *
162
     * @return array
163
     */
164 1
    public function setOrganization($id, $organizationId)
165
    {
166 1
        return $this->put($this->getPath().'/'.rawurlencode($id).'/idOrganization/'.rawurlencode($organizationId));
167
    }
168
169
    /**
170
     * Get a given board's organization
171
     * @link https://trello.com/docs/api/board/#get-1-boards-board-id-organization
172
     *
173
     * @param string $id     the board's id
174
     * @param array  $params optional parameters
175
     *
176
     * @return array
177
     */
178 1
    public function getOrganization($id, array $params = array())
179
    {
180 1
        return $this->get($this->getPath().'/'.rawurlencode($id).'/organization', $params);
181
    }
182
183
    /**
184
     * Get the field of the organization of a given board
185
     * @link https://trello.com/docs/api/board/#get-1-boards-board-id-organization-field
186
     *
187
     * @param string $id    the board's id
188
     * @param string $field the organization's field name
189
     *
190
     * @return array
191
     */
192 2
    public function getOrganizationField($id, $field)
193
    {
194 2
        $this->validateAllowedParameters(Organization::$fields, $field, 'field');
195
196 1
        return $this->get($this->getPath().'/'.rawurlencode($id).'/organization/'.rawurlencode($field));
197
    }
198
199
    /**
200
     * Get a given board's stars
201
     * @link https://trello.com/docs/api/board/#get-1-boards-board-id-boardstars
202
     *
203
     * @param string $id     the board's id
204
     * @param array  $params optional parameters
205
     *
206
     * @return array
207
     */
208 1
    public function getStars($id, array $params = array())
209
    {
210 1
        return $this->get($this->getPath().'/'.rawurlencode($id).'/boardStars', $params);
211
    }
212
213
    /**
214
     * Get a given board's deltas
215
     * @link https://trello.com/docs/api/board/index.html#get-1-boards-board-id-deltas
216
     *
217
     * @param string $id     the board's id
218
     * @param array  $params optional parameters
219
     *
220
     * @return array
221
     */
222 1
    public function getDeltas($id, array $params = array())
223
    {
224 1
        return $this->get($this->getPath().'/'.rawurlencode($id).'/deltas', $params);
225
    }
226
227
    /**
228
     * Mark a given board as viewed
229
     * @link https://trello.com/docs/api/board/#post-1-boards-board-id-markasviewed
230
     *
231
     * @param string $id the board's id
232
     *
233
     * @return array
234
     */
235 1
    public function setViewed($id)
236
    {
237 1
        return $this->post($this->getPath().'/'.rawurlencode($id).'/markAsViewed');
238
    }
239
240
    /**
241
     * Board Actions API
242
     *
243
     * @return Board\Actions
244
     */
245 1
    public function actions()
246
    {
247 1
        return new Board\Actions($this->client);
248
    }
249
250
    /**
251
     * Board Lists API
252
     *
253
     * @return Board\Cardlists
254
     */
255 1
    public function lists()
256
    {
257 1
        return new Board\Cardlists($this->client);
258
    }
259
260
    /**
261
     * Board Cards API
262
     *
263
     * @return Board\Cards
264
     */
265 1
    public function cards()
266
    {
267 1
        return new Board\Cards($this->client);
268
    }
269
270
    /**
271
     * Board Checklists API
272
     *
273
     * @return Board\Checklists
274
     */
275 1
    public function checklists()
276
    {
277 1
        return new Board\Checklists($this->client);
278
    }
279
280
    /**
281
     * Board Labels API
282
     *
283
     * @return Board\Labels
284
     */
285 1
    public function labels()
286
    {
287 1
        return new Board\Labels($this->client);
288
    }
289
290
    /**
291
     * Board Members API
292
     *
293
     * @return Board\Members
294
     */
295 1
    public function members()
296
    {
297 1
        return new Board\Members($this->client);
298
    }
299
300
    /**
301
     * Board Memberships API
302
     *
303
     * @return Board\Memberships
304
     */
305 1
    public function memberships()
306
    {
307 1
        return new Board\Memberships($this->client);
308
    }
309
310
    /**
311
     * Board Preferences API
312
     *
313
     * @return Board\Preferences
314
     */
315 1
    public function preferences()
316
    {
317 1
        return new Board\Preferences($this->client);
318
    }
319
320
    /**
321
     * Board MyPreferences API
322
     *
323
     * @return Board\MyPreferences
324
     */
325 1
    public function myPreferences()
326
    {
327 1
        return new Board\MyPreferences($this->client);
328
    }
329
330
    /**
331
     * Board PowerUps API
332
     *
333
     * @return Board\PowerUps
334
     */
335 1
    public function powerUps()
336
    {
337 1
        return new Board\PowerUps($this->client);
338
    }
339
}
340