Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
92.31% |
12 / 13 |
|
75.00% |
3 / 4 |
CRAP | |
0.00% |
0 / 1 |
| IssueUpdateRequest | |
92.31% |
12 / 13 |
|
75.00% |
3 / 4 |
6.02 | |
0.00% |
0 / 1 |
| idOrKey | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getIdOrKey | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| validate | |
50.00% |
1 / 2 |
|
0.00% |
0 / 1 |
2.50 | |||
| toArray | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Javidnikoo\LaravelAtlassian\Jira\Features\Issue\Requests; |
| 4 | |
| 5 | use Javidnikoo\LaravelAtlassian\Jira\Exceptions\JiraException; |
| 6 | |
| 7 | class IssueUpdateRequest extends IssueCreateRequest |
| 8 | { |
| 9 | protected string $idOrKey; |
| 10 | |
| 11 | public function idOrKey(string $idOrKey): self |
| 12 | { |
| 13 | $this->idOrKey = $idOrKey; |
| 14 | |
| 15 | return $this; |
| 16 | } |
| 17 | |
| 18 | public function getIdOrKey(): string |
| 19 | { |
| 20 | return $this->idOrKey; |
| 21 | } |
| 22 | |
| 23 | protected function validate(): void |
| 24 | { |
| 25 | if (empty($this->idOrKey)) { |
| 26 | throw new JiraException('ID or key is required for update.'); |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | public function toArray(): array |
| 31 | { |
| 32 | $this->validate(); |
| 33 | |
| 34 | if (! empty($this->descriptionContent)) { |
| 35 | $this->fields['description'] = [ |
| 36 | 'type' => 'doc', |
| 37 | 'version' => 1, |
| 38 | 'content' => $this->descriptionContent, |
| 39 | ]; |
| 40 | } |
| 41 | |
| 42 | return ['fields' => $this->fields]; |
| 43 | } |
| 44 | } |