Organizations::invitedToField()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Trello\Api\Member;
4
5
use Trello\Api\AbstractApi;
6
use Trello\Api\Organization;
7
use Trello\Exception\InvalidArgumentException;
8
9
/**
10
 * Trello Member Organizations API
11
 * @link https://trello.com/docs/api/member
12
 *
13
 * Fully implemented.
14
 */
15
class Organizations extends AbstractApi
16
{
17
    protected $path = 'members/#id#/organizations';
18
19
    /**
20
     * Get organizations related to a given member
21
     * @link https://trello.com/docs/api/member/#get-1-members-idmember-or-username-organizations
22
     *
23
     * @param string $id     the member's id or username
24
     * @param array  $params optional parameters
25
     *
26
     * @return array
27
     */
28 1
    public function all($id, array $params = array())
29
    {
30 1
        return $this->get($this->getPath($id), $params);
31
    }
32
33
    /**
34
     * Filter organizations related to a given member
35
     * @link https://trello.com/docs/api/member/#get-1-members-idmember-or-username-organizations-filter
36
     *
37
     * @param string       $id     the organization's id
38
     * @param string|array $filter array of / one of 'all', 'none', 'members', 'public'
39
     *
40
     * @return array
41
     */
42 3
    public function filter($id, $filter = 'all')
43
    {
44 3
        $allowed = array('all', 'none', 'members', 'public');
45 3
        $filters = $this->validateAllowedParameters($allowed, $filter, 'filter');
46
47 3
        return $this->get($this->getPath($id).'/'.implode(',', $filters));
48
    }
49
50
    /**
51
     * Get organizations a given member is invited to
52
     * @link https://trello.com/docs/api/member/#get-1-members-idmember-or-username-organizationsinvited
53
     *
54
     * @param string $id     the member's id or username
55
     * @param array  $params optional parameters
56
     *
57
     * @return array
58
     */
59 1
    public function invitedTo($id, array $params = array())
60
    {
61 1
        return $this->get($this->getPath($id).'Invited', $params);
62
    }
63
64
    /**
65
     * Get a field of an organization a given member is invited to
66
     * @link https://trello.com/docs/api/member/#get-1-members-idmember-or-username-organizationsinvited-field
67
     *
68
     * @param string $id     the member's id or username
69
     *
70
     * @return array
71
     */
72 2
    public function invitedToField($id, $field)
73
    {
74 2
        $this->validateAllowedParameters(Organization::$fields, $field, 'field');
75
76 1
        return $this->get($this->getPath($id).'Invited/'.rawurlencode($field));
77
    }
78
}
79