Stickers   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 101
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 101
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A all() 0 4 1
A show() 0 7 1
A update() 0 7 1
A create() 0 7 1
A remove() 0 4 1
1
<?php
2
3
namespace Trello\Api\Card;
4
5
use Trello\Api\AbstractApi;
6
7
/**
8
 * Trello Card Stickers API
9
 * @link https://trello.com/docs/api/card
10
 *
11
 * Fully implemented.
12
 */
13
class Stickers extends AbstractApi
14
{
15
    protected $path = 'cards/#id#/stickers';
16
17
    /**
18
     * Get stickers related to a given card
19
     * @link https://trello.com/docs/api/card/#get-1-cards-card-id-or-shortlink-stickers
20
     *
21
     * @param string $id     the card's id or short link
22
     * @param array  $params optional parameters
23
     *
24
     * @return array
25
     */
26 1
    public function all($id, array $params = array())
27
    {
28 1
        return $this->get($this->getPath($id), $params);
29
    }
30
31
    /**
32
     * Get a given sticker on a given card
33
     * @link https://trello.com/docs/api/card/#get-1-cards-card-id-or-shortlink-stickers-idsticker
34
     *
35
     * @param string       $id        the card's id or short link
36
     * @param string       $stickerId the sticker's id
37
     * @param string|array $fields    'all' or a array of:
38
     *                                - image
39
     *                                - imageScaled
40
     *                                - imageUrl
41
     *                                - left
42
     *                                - rotate
43
     *                                - top
44
     *                                - zIndex
45
     *                                Defaults to 'all'
46
     *
47
     * @return array
48
     */
49 1
    public function show($id, $stickerId, $fields = 'all')
50
    {
51 1
        $allowed = array('all', 'image', 'imageScaled', 'imageUrl', 'left', 'rotate', 'top', 'zIndex');
52 1
        $fields = $this->validateAllowedParameters($allowed, $fields, 'field');
53
54 1
        return $this->get($this->getPath($id).'/'.rawurlencode($stickerId), $fields);
55
    }
56
57
    /**
58
     * Update a given sticker on a given card
59
     * @link https://trello.com/docs/api/card/#put-1-cards-card-id-or-shortlink-stickers-idsticker
60
     *
61
     * @param string $id        the card's id or short link
62
     * @param string $stickerId the sticker's id
63
     * @param array  $params    Parameters to update (all optional but at least one of them is required):
64
     *                          - left
65
     *                          - rotate
66
     *                          - top
67
     *                          - zIndex
68
     *
69
     * @return array
70
     */
71 2
    public function update($id, $stickerId, array $params)
72
    {
73 2
        $oneOf = array('left', 'rotate', 'top', 'zIndex');
74 2
        $this->validateAtLeastOneOf($oneOf, $params);
75
76 1
        return $this->put($this->getPath($id).'/'.rawurlencode($stickerId), $params);
77
    }
78
79
    /**
80
     * Create a given sticker on a given card
81
     * @link https://trello.com/docs/api/card/#put-1-cards-card-id-or-shortlink-stickers-idsticker
82
     *
83
     * @param  string $id     the card's id or short link
84
     * @param  array  $params Properties of the sticker
85
     *                        - image (string)
86
     *                        - top
87
     *                        - left
88
     *                        - zIndex
89
     *                        - rotate (optional, default 0)
90
     * @return array
91
     */
92 2
    public function create($id, array $params)
93
    {
94 2
        $required = array('image', 'left', 'top', 'zIndex');
95 2
        $this->validateRequiredParameters($required, $params);
96
97 1
        return $this->post($this->getPath($id), $params);
98
    }
99
100
    /**
101
     * Remove a given sticker from a given card
102
     * @link https://trello.com/docs/api/card/#delete-1-cards-card-id-or-shortlink-stickers-idsticker
103
     *
104
     * @param string $id        the card's id or short link
105
     * @param string $stickerId the sticker's id
106
     *
107
     * @return array
108
     */
109 1
    public function remove($id, $stickerId)
110
    {
111 1
        return $this->delete($this->getPath($id).'/'.rawurlencode($stickerId));
112
    }
113
}
114