Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php |
||
21 | class WorklogEndpoint extends IssueEndpoint implements EndpointInterface |
||
22 | { |
||
23 | const EP_WORKLOG = 'worklog'; |
||
24 | |||
25 | const PARAM_ADJUST_ESTIMATE = 'adjustEstimate'; |
||
26 | const PARAM_NEW_ESTIMATE = 'newEstimate'; |
||
27 | const PARAM_REDUCE_BY = 'reduceBy'; |
||
28 | const PARAM_INCREASE_BY = 'increaseBy'; |
||
29 | |||
30 | const PAYLOAD_COMMENT = 'comment'; |
||
31 | const PAYLOAD_VISIBILITY = 'visibility'; |
||
32 | const PAYLOAD_VISIBILITY_TYPE = 'type'; |
||
33 | const PAYLOAD_VISIBILITY_VALUE = 'value'; |
||
34 | const PAYLOAD_STARTED = 'started'; |
||
35 | const PAYLOAD_TIME_SPENT = 'timeSpent'; |
||
36 | const PAYLOAD_TIME_SPENT_SECONDS = 'timeSpentSeconds'; |
||
37 | |||
38 | /** |
||
39 | * Get list of worklogs for an issue [STATUS 200] |
||
40 | * |
||
41 | * @param string $issue JIRA ticket number |
||
42 | * |
||
43 | * @return array |
||
44 | */ |
||
45 | public function listWorklog($issue) |
||
49 | |||
50 | /** |
||
51 | * Add worklog for an issue [STATUS 201] |
||
52 | * |
||
53 | * @param string $issue JIRA ticket number |
||
54 | * |
||
55 | * @param string $timeSpent How much time spent (e.g. '3h 30m') |
||
56 | * @param string|null $comment [optional] Comment |
||
57 | * @param string|null $started [optional] Set date of work |
||
58 | * |
||
59 | * @param string|null $adjustEstimate [optional] Allows you to provide specific instructions to update the |
||
60 | * remaining time estimate of the issue. Valid values are |
||
61 | * "new" - sets the estimate to a specific value |
||
62 | * "leave"- leaves the estimate as is |
||
63 | * "manual" - specify a specific amount to increase remaining estimate by |
||
64 | * "auto"- Default option. Will automatically adjust the value based on the new |
||
65 | * timeSpent specified on the worklog |
||
66 | * @param string|null $newEstimate (required when "new" is selected for adjustEstimate) the new value for the |
||
67 | * remaining estimate field. e.g. "2d" |
||
68 | * @param string|null $reduceBy (required when "manual" is selected for adjustEstimate) the amount to reduce |
||
69 | * the remaining estimate by e.g. "2d" |
||
70 | * |
||
71 | * @return array |
||
72 | */ |
||
73 | View Code Duplication | public function addWorklog( |
|
100 | |||
101 | /** |
||
102 | * Update worklog for an issue [STATUS 200] |
||
103 | * |
||
104 | * @param string $issue JIRA ticket number |
||
105 | * @param string $worklogId Worklog ID |
||
106 | * |
||
107 | * @param string $timeSpent How much time spent (e.g. '3h 30m') |
||
108 | * @param string|null $comment [optional] Comment |
||
109 | * @param string|null $started [optional] Set date of work |
||
110 | * |
||
111 | * @param string|null $adjustEstimate [optional] Allows you to provide specific instructions to update the |
||
112 | * remaining time estimate of the issue. Valid values are |
||
113 | * "new" - sets the estimate to a specific value |
||
114 | * "leave"- leaves the estimate as is |
||
115 | * "manual" - specify a specific amount to increase remaining estimate by |
||
116 | * "auto"- Default option. Will automatically adjust the value based on the new |
||
117 | * timeSpent specified on the worklog |
||
118 | * @param string|null $newEstimate (required when "new" is selected for adjustEstimate) the new value for the |
||
119 | * remaining estimate field. e.g. "2d" |
||
120 | * |
||
121 | * @return array |
||
122 | */ |
||
123 | View Code Duplication | public function updateWorklog( |
|
149 | |||
150 | /** |
||
151 | * Delete worklog for an issue [STATUS 204] |
||
152 | * |
||
153 | * @param string $issue JIRA ticket number |
||
154 | * @param string $worklogId Worklog ID |
||
155 | * |
||
156 | * @param string|null $adjustEstimate [optional] Allows you to provide specific instructions to update the |
||
157 | * remaining time estimate of the issue. Valid values are |
||
158 | * "new" - sets the estimate to a specific value |
||
159 | * "leave"- leaves the estimate as is |
||
160 | * "manual" - specify a specific amount to increase remaining estimate by |
||
161 | * "auto"- Default option. Will automatically adjust the value based on the new |
||
162 | * timeSpent specified on the worklog |
||
163 | * @param string|null $newEstimate (required when "new" is selected for adjustEstimate) the new value for the |
||
164 | * remaining estimate field. e.g. "2d" |
||
165 | * @param string|null $increaseBy (required when "manual" is selected for adjustEstimate) the amount to |
||
166 | * increase the remaining estimate by e.g. "2d" |
||
167 | * |
||
168 | * @return array |
||
169 | */ |
||
170 | public function deleteWorklog($issue, $worklogId, $adjustEstimate = null, $newEstimate = null, $increaseBy = null) |
||
185 | } |
||
186 |