1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace TrelloBurndown; |
4
|
|
|
|
5
|
|
|
use Trello\Model\Board; |
6
|
|
|
use Trello\Model\Cardlist; |
7
|
|
|
use TrelloBurndown\Client\TrelloClient; |
8
|
|
|
use TrelloBurndown\Exception\TrelloItemNotFoundException; |
9
|
|
|
use TrelloBurndown\Manager\ActionManager; |
10
|
|
|
use TrelloBurndown\Manager\BoardManager; |
11
|
|
|
use TrelloBurndown\Manager\ListManager; |
12
|
|
|
use TrelloBurndown\Manager\StoryPointManager; |
13
|
|
|
use TrelloBurndown\Model\Sprint; |
14
|
|
|
use TrelloBurndown\Model\StoryPointBurndown; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Class BurndownGenerator. |
18
|
|
|
*/ |
19
|
|
|
class BurndownGenerator |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @var TrelloClient |
23
|
|
|
*/ |
24
|
|
|
private $client; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var BoardManager |
28
|
|
|
*/ |
29
|
|
|
private $boardManager; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var ListManager |
33
|
|
|
*/ |
34
|
|
|
private $listManager; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var ActionManager |
38
|
|
|
*/ |
39
|
|
|
private $actionManager; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var StoryPointManager |
43
|
|
|
*/ |
44
|
|
|
private $storyPointManager; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @var array |
48
|
|
|
*/ |
49
|
|
|
private $boards = []; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @var array |
53
|
|
|
*/ |
54
|
|
|
private $todoLists = []; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @var array |
58
|
|
|
*/ |
59
|
|
|
private $wipLists = []; |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @var array |
63
|
|
|
*/ |
64
|
|
|
private $doneLists = []; |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* BurndownGenerator constructor. |
68
|
|
|
* |
69
|
|
|
* @param TrelloClient $client |
70
|
|
|
*/ |
71
|
12 |
|
public function __construct(TrelloClient $client) |
72
|
|
|
{ |
73
|
12 |
|
$this->client = $client; |
74
|
12 |
|
$this->boardManager = new BoardManager($this->client); |
75
|
12 |
|
$this->listManager = new ListManager($this->client); |
76
|
12 |
|
$this->actionManager = new ActionManager($this->client); |
77
|
12 |
|
$this->storyPointManager = new StoryPointManager($this->client, $this->actionManager); |
78
|
12 |
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @param string $boardName |
82
|
|
|
* |
83
|
|
|
* @throws \Exception |
84
|
|
|
*/ |
85
|
10 |
|
public function addBoard(String $boardName) |
86
|
|
|
{ |
87
|
10 |
|
$board = $this->boardManager->getBoard($boardName); |
88
|
10 |
|
if ($board == null || !$board instanceof Board) { |
89
|
1 |
|
throw new TrelloItemNotFoundException('board', $boardName); |
90
|
|
|
} |
91
|
9 |
|
$this->boards[] = $board; |
92
|
9 |
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @param array $lists |
96
|
|
|
* @param string $listName |
97
|
|
|
* @param $boardName |
98
|
|
|
* |
99
|
|
|
* @throws \Exception |
100
|
|
|
*/ |
101
|
9 |
|
private function addList(array &$lists, String $listName, $boardName) |
102
|
|
|
{ |
103
|
9 |
|
if ($boardName !== null) { |
104
|
5 |
|
$board = $this->boardManager->getBoard($boardName); |
105
|
|
|
|
106
|
5 |
|
if ($board == null || !$board instanceof Board) { |
107
|
1 |
|
throw new TrelloItemNotFoundException('board', $boardName); |
108
|
|
|
} |
109
|
|
|
|
110
|
4 |
|
$list = $this->listManager->getListFromBoard($listName, $board); |
111
|
|
|
|
112
|
4 |
|
if ($list == null || !$list instanceof Cardlist) { |
113
|
|
|
throw new TrelloItemNotFoundException('list', $listName); |
114
|
|
|
} |
115
|
|
|
|
116
|
4 |
|
$lists[] = $list; |
117
|
|
|
} else { |
118
|
4 |
|
$list = $this->listManager->getList($listName, $this->boards); |
119
|
4 |
|
if ($list == null || !$list instanceof Cardlist) { |
120
|
1 |
|
throw new TrelloItemNotFoundException('list', $listName); |
121
|
|
|
} |
122
|
3 |
|
$lists[] = $list; |
123
|
|
|
} |
124
|
7 |
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* @param string $listName |
128
|
|
|
* @param string|null $boardName |
129
|
|
|
*/ |
130
|
3 |
|
public function addTodoList(String $listName, String $boardName = null) |
131
|
|
|
{ |
132
|
3 |
|
$this->addList($this->todoLists, $listName, $boardName); |
133
|
3 |
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* @param string $listName |
137
|
|
|
* @param string|null $boardName |
138
|
|
|
*/ |
139
|
5 |
|
public function addWipList(String $listName, String $boardName = null) |
140
|
|
|
{ |
141
|
5 |
|
$this->addList($this->wipLists, $listName, $boardName); |
142
|
3 |
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* @param string $listName |
146
|
|
|
* @param string|null $boardName |
147
|
|
|
*/ |
148
|
3 |
|
public function addDoneList(String $listName, String $boardName = null) |
149
|
|
|
{ |
150
|
3 |
|
$this->addList($this->doneLists, $listName, $boardName); |
151
|
3 |
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* @return array |
155
|
|
|
*/ |
156
|
5 |
|
public function getBoards() |
157
|
|
|
{ |
158
|
5 |
|
return $this->boards; |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* @return array |
163
|
|
|
*/ |
164
|
2 |
|
public function getTodoLists() |
165
|
|
|
{ |
166
|
2 |
|
return $this->todoLists; |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
/** |
170
|
|
|
* @return array |
171
|
|
|
*/ |
172
|
2 |
|
public function getWipLists() |
173
|
|
|
{ |
174
|
2 |
|
return $this->wipLists; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* @return array |
179
|
|
|
*/ |
180
|
2 |
|
public function getDoneLists() |
181
|
|
|
{ |
182
|
2 |
|
return $this->doneLists; |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
/** |
186
|
|
|
* @param Sprint $sprint |
187
|
|
|
* |
188
|
|
|
* @return StoryPointBurndown |
189
|
|
|
*/ |
190
|
1 |
|
public function getStoryPointBurndown(Sprint $sprint) |
191
|
|
|
{ |
192
|
1 |
|
$doneSP = $this->storyPointManager->getDoneStoryPoints($this->todoLists, $this->wipLists, $this->doneLists, $sprint); |
193
|
1 |
|
$total = $this->storyPointManager->getTotalSprintStoryPoints($this->todoLists, $this->wipLists, $this->doneLists, $sprint); |
194
|
1 |
|
$average = $this->storyPointManager->getAverageStoryPointsPerDay($total, $sprint); |
195
|
|
|
|
196
|
1 |
|
$burndown = new StoryPointBurndown($sprint, $total, $doneSP, $average); |
|
|
|
|
197
|
|
|
|
198
|
1 |
|
return $burndown; |
199
|
|
|
} |
200
|
|
|
} |
201
|
|
|
|
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.