Completed
Push — master ( 5cc041...a53be1 )
by Thijs
01:12
created

TransformsAttachments   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 32
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A toDevOpsAttachment() 0 16 1
A fromDevOpsAttachment() 0 4 1
1
<?php
2
3
namespace TestMonitor\DevOps\Transforms;
4
5
use TestMonitor\DevOps\Resources\Attachment;
6
7
trait TransformsAttachments
8
{
9
    /**
10
     * @param string $attachmentUrl
11
     * @return array
12
     */
13 1
    protected function toDevOpsAttachment(string $attachmentUrl): array
14
    {
15
        return [
16
            [
17 1
                'op' => 'add',
18 1
                'path'=> '/relations/-',
19
                'value'=> [
20 1
                    'rel' => 'AttachedFile',
21 1
                    'url' => $attachmentUrl,
22
                    'attributes' => [
23
                        'comment' => '',
24
                    ],
25
                ],
26
            ],
27
        ];
28
    }
29
30
    /**
31
     * @param array $attachment
32
     * @return \TestMonitor\DevOps\Resources\Attachment
33
     */
34 1
    protected function fromDevOpsAttachment(array $attachment): Attachment
35
    {
36 1
        return new Attachment($attachment['url'], $attachment['id']);
37
    }
38
}
39