Completed
Pull Request — master (#16)
by
unknown
07:58
created

CustomFieldItems   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 45
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A all() 0 7 2
A update() 0 9 1
1
<?php
2
3
namespace Trello\Api\Card;
4
5
use Trello\Api\AbstractApi;
6
7
/**
8
 * Trello Card custom fields items API
9
 * @link https://developers.trello.com/docs/getting-started-custom-fields#section-custom-field-values-on-cards
10
 *
11
 */
12
class CustomFieldItems extends AbstractApi
13
{
14
    /**
15
     * Base path of cards api
16
     * @var string
17
     */
18
    protected $path = 'cards/#id#/';
19
20
    /**
21
     * Get custom fiedls items related to a given card
22
     * @link https://developers.trello.com/docs/getting-started-custom-fields#section-getting-customfielditems-for-cards
23
     *
24
     * @param string $id     the card's id or short link
25
     * @param array  $params optional parameters
26
     *
27
     * @return array
28
     */
29
    public function all($id, array $params = array())
30
    {
31
        $params = array_merge($params, array('customFieldItems' => 'true'));
32
        $data = $this->get($this->getPath($id), $params);
33
34
        return array_key_exists('customFieldItems', $data) ? $data['customFieldItems'] : array();
35
    }
36
37
    /**
38
     * Update a given custom field value on a given card
39
     * @link https://developers.trello.com/docs/getting-started-custom-fields#section-setting-updating-customfielditems
40
     *
41
     * @param string $id            the card's id or short link
42
     * @param string $customFieldId the card's id or short link
43
     * @param array  $value        the member's id
44
     *
45
     * @return array
46
     */
47
    public function update($id, $customFieldId, $value = array())
48
    {
49
        $path = $this->getPath($id) . 'customField/' . rawurldecode($customFieldId) . '/item';
50
51
        return $this->put(
52
            $path,
53
            $value
54
        );
55
    }
56
}
57