Passed
Push — master ( 6aff30...239879 )
by Thijs
09:39
created

ManagesWorkItems   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 42
ccs 9
cts 9
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A workitem() 0 5 1
A createWorkItem() 0 11 1
1
<?php
2
3
namespace TestMonitor\DevOps\Actions;
4
5
use TestMonitor\DevOps\Resources\WorkItem;
6
use TestMonitor\DevOps\Transforms\TransformsWorkItems;
7
8
trait ManagesWorkItems
9
{
10
    use TransformsWorkItems;
11
12
    /**
13
     * Get a single work item.
14
     *
15
     * @param string $id
16
     * @param string $projectId
17
     *
18
     * @throws \TestMonitor\DevOps\Exceptions\InvalidDataException
19
     *
20
     * @return \TestMonitor\DevOps\Resources\WorkItem
21
     */
22 4
    public function workitem(string $id, string $projectId): WorkItem
23
    {
24 4
        $response = $this->get("{$projectId}/_apis/wit/workitems/{$id}");
0 ignored issues
show
Bug introduced by
It seems like get() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

24
        /** @scrutinizer ignore-call */ 
25
        $response = $this->get("{$projectId}/_apis/wit/workitems/{$id}");
Loading history...
25
26 1
        return $this->fromDevOpsWorkItem($response);
27
    }
28
29
    /**
30
     * Create a new work item.
31
     *
32
     * @param \TestMonitor\DevOps\Resources\WorkItem $workItem
33
     * @param string $projectId
34
     *
35
     * @throws \TestMonitor\DevOps\Exceptions\InvalidDataException
36
     *
37
     * @return WorkItem
38
     */
39 2
    public function createWorkItem(WorkItem $workItem, string $projectId): WorkItem
40
    {
41 2
        $response = $this->post(
0 ignored issues
show
Bug introduced by
It seems like post() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

41
        /** @scrutinizer ignore-call */ 
42
        $response = $this->post(
Loading history...
42 2
            "{$projectId}/_apis/wit/workitems/\${$workItem->workItemType}",
43
            [
44 2
                'headers' => ['Content-Type' => 'application/json-patch+json'],
45 2
                'json' => $this->toDevOpsWorkItem($workItem),
46
            ]
47
        );
48
49 1
        return $this->fromDevOpsWorkItem($response);
50
    }
51
}
52