Completed
Push — master ( 569933...98080f )
by Philip
03:39
created

Project::releaseBuilds()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Manavo\DoneDone;
4
5
class Project
6
{
7
8
    /**
9
     * @var Client
10
     */
11
    private $client;
12
13
    /**
14
     * @var int
15
     */
16
    private $id;
17
18
    /**
19
     * @param Client $client
20
     * @param int    $id
21
     */
22 63
    function __construct($client, $id)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
23
    {
24 63
        $this->client = $client;
25 63
        $this->id = $id;
26 63
    }
27
28
    /**
29
     * Get all the people associated with this project
30
     *
31
     * @return array
32
     */
33 3
    public function people()
34
    {
35 3
        return $this->client->get('projects/' . $this->id . '/people');
36
    }
37
38
    /**
39
     * Get all the issues associated with this project
40
     *
41
     * @return array
42
     */
43 3
    public function issues()
44
    {
45 3
        return $this->client->get('projects/' . $this->id . '/issues/all');
46
    }
47
48
    /**
49
     * @param int $id
50
     *
51
     * @return Issue
52
     */
53 27
    public function issue($id)
54
    {
55 27
        return new Issue($this->client, $this->id, $id);
56
    }
57
58
    /**
59
     * Get all the active issues associated with this project
60
     *
61
     * @return array
62
     */
63 3
    public function activeIssues()
64
    {
65 3
        return $this->client->get(
66 3
            'projects/' . $this->id . '/issues/all_active'
67 3
        );
68
    }
69
70
    /**
71
     * Get all the closed and fixed issues associated with this project
72
     *
73
     * @return array
74
     */
75 3
    public function closedAndFixedIssues()
76
    {
77 3
        return $this->client->get(
78 3
            'projects/' . $this->id . '/issues/all_closed_and_fixed'
79 3
        );
80
    }
81
82
    /**
83
     * Get all the issues by a filter associated with this project
84
     *
85
     * @param int $filter
86
     *
87
     * @return array
88
     */
89 3
    public function issuesByFilter($filter)
90
    {
91 3
        return $this->client->get(
92 3
            sprintf(
93 3
                'projects/%d/issues/by_custom_filter/%d',
94 3
                $this->id,
95
                $filter
96 3
            )
97 3
        );
98
    }
99
100
    /**
101
     * Get all the issues which are waiting on you, and are associated with
102
     * this project
103
     *
104
     * @return array
105
     */
106 3
    public function issuesWaitingOnYou()
107
    {
108 3
        return $this->client->get(
109 3
            sprintf('projects/%d/issues/waiting_on_you', $this->id)
110 3
        );
111
    }
112
113
    /**
114
     * Get all the issues which are waiting on them
115
     *
116
     * @return array
117
     */
118 3
    public function issuesWaitingOnThem()
119
    {
120 3
        return $this->client->get(
121 3
            sprintf('projects/%d/issues/waiting_on_them', $this->id)
122 3
        );
123
    }
124
125
    /**
126
     * Get release builds of this project
127
     *
128
     * @return array
129
     */
130 3
    public function releaseBuilds()
131
    {
132 3
        return $this->client->get('projects/' . $this->id . '/release_builds');
133
    }
134
135
    /**
136
     * Get release builds of this project
137
     *
138
     * @return ReleaseBuildInfo
139
     */
140
    public function releaseBuildInfo()
141
    {
142
        return new ReleaseBuildInfo($this->client->get('projects/' . $this->id . '/release_builds/info'));
143
    }
144
145
    /**
146
     * Get filters of this project
147
     *
148
     * @return array
149
     */
150 3
    public function filters()
151
    {
152 3
        return $this->client->get('projects/' . $this->id . '/custom_filters');
153
    }
154
155
    /**
156
     * Add a new issue to the project
157
     *
158
     * @param Issue $issue
159
     *
160
     * @return array
161
     */
162 3
    public function addIssue($issue)
163
    {
164 3
        return $this->client->post(
165 3
            'projects/' . $this->id . '/issues', $issue->toArray()
166 3
        );
167
    }
168
169
    /**
170
     * Create a new release build for the project
171
     *
172
     * @param ReleaseBuild $releaseBuild
173
     *
174
     * @return array
175
     */
176 3
    public function createReleaseBuild($releaseBuild)
177
    {
178 3
        return $this->client->post(
179 3
            sprintf('projects/%d/release_builds', $this->id),
180 3
            $releaseBuild->toArray()
181 3
        );
182
    }
183
184
}
185