Notification Setup Error

We have detected an error in your notification set-up (Event-ID dab39dc24f564ec7bd4628d1305fd03c). Currently, we cannot inform you about inspection progress. Please check that the user 557058:bca11929-8c2d-43f2-8a82-c5416880d395 still has access to your repository or update the API account.

Completed
Push — develop ( 39a772...87d9d9 )
by
unknown
46:15 queued 31:17
created

Teams::members()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

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 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
/**
4
 * This file is part of the bitbucket-api package.
5
 *
6
 * (c) Alexandru G. <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
namespace Bitbucket\API;
12
13
use Psr\Http\Message\ResponseInterface;
14
15
/**
16
 * @author  Alexandru G.    <[email protected]>
17
 */
18
class Teams extends Api
19
{
20
    /**
21
     * Get a list of teams to which the caller has access.
22
     *
23
     * @access public
24
     * @param  string           $role Will only return teams on which the user has the specified role.
25
     * @return ResponseInterface
26
     *
27
     * @throws \InvalidArgumentException
28
     */
29 8
    public function all($role)
30
    {
31 8
        if (!is_string($role)) {
32 5
            throw new \InvalidArgumentException(sprintf('Expected $role of type string and got %s', gettype($role)));
33
        }
34
35 3
        if (!in_array(strtolower($role), array('member', 'contributor', 'admin'), true)) {
36 2
            throw new \InvalidArgumentException(sprintf('Unknown role %s', $role));
37
        }
38
39 1
        return $this->getClient()->setApiVersion('2.0')->get('/teams', array('role' => $role));
40
    }
41
42
    /**
43
     * Get the public information associated with a team.
44
     *
45
     * @access public
46
     * @param  string           $name The team's name.
47
     * @return ResponseInterface
48
     */
49 1
    public function profile($name)
50
    {
51 1
        return $this->getClient()->setApiVersion('2.0')->get(
52 1
            sprintf('/teams/%s', $name)
53
        );
54
    }
55
56
    /**
57
     * Get the team members.
58
     *
59
     * @access public
60
     * @param  string           $name The team's name.
61
     * @return ResponseInterface
62
     */
63 1
    public function members($name)
64
    {
65 1
        return $this->getClient()->setApiVersion('2.0')->get(
66 1
            sprintf('/teams/%s/members', $name)
67
        );
68
    }
69
70
    /**
71
     * Get the team followers list.
72
     *
73
     * @access public
74
     * @param  string           $name The team's name.
75
     * @return ResponseInterface
76
     */
77 1
    public function followers($name)
78
    {
79 1
        return $this->getClient()->setApiVersion('2.0')->get(
80 1
            sprintf('/teams/%s/followers', $name)
81
        );
82
    }
83
84
    /**
85
     * Get a list of accounts the team is following.
86
     *
87
     * @access public
88
     * @param  string           $name The team's name.
89
     * @return ResponseInterface
90
     */
91 1
    public function following($name)
92
    {
93 1
        return $this->getClient()->setApiVersion('2.0')->get(
94 1
            sprintf('/teams/%s/following', $name)
95
        );
96
    }
97
98
    /**
99
     * Get the team's repositories.
100
     *
101
     * @access public
102
     * @param  string           $name The team's name.
103
     * @return ResponseInterface
104
     */
105 1
    public function repositories($name)
106
    {
107 1
        return $this->getClient()->setApiVersion('2.0')->get(
108 1
            sprintf('/teams/%s/repositories', $name)
109
        );
110
    }
111
112
    /**
113
     * @return Teams\Hooks
114
     * @throws \InvalidArgumentException
115
     */
116
    public function hooks()
117
    {
118
        return $this->api(Teams\Hooks::class);
119
    }
120
}
121