Passed
Push — develop ( a76660...a777ee )
by Daniel
02:23 queued 46s
created

RetrieveResponse   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A from() 0 11 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace InShore\Bookwhen\Responses\Attachments;
6
7
use InShore\Bookwhen\Contracts\ResponseContract;
8
9
/**
10
 * @implements ResponseContract<array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|string|null}>
11
 */
12
final class RetrieveResponse implements ResponseContract
13
{
14
    /**
15
     * @param  array<array-key, mixed>|null  $statusDetails
0 ignored issues
show
Documentation Bug introduced by
The doc comment array<array-key, mixed>|null at position 2 could not be parsed: Unknown type name 'array-key' at position 2 in array<array-key, mixed>|null.
Loading history...
16
     */
17 2
    private function __construct(
18
        public readonly null | string $contentType,
19
        public readonly null | string $fileName,
20
        public readonly null | string $fileSizeBytes,
21
        public readonly null | string $fileSizeText,
22
        public readonly null | string $fileType,
23
        public readonly null | string $fileUrl,
24
        public readonly string $id,
25
        public readonly null | string $title
26
    ) {
27 2
    }
28
29
    /**
30
     * Acts as static factory, and returns a new Response instance.
31
     *
32
     * @param  array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|string|null}  $attributes
0 ignored issues
show
Documentation Bug introduced by
The doc comment array{id: string, object...ey, mixed>|string|null} at position 34 could not be parsed: Unknown type name 'array-key' at position 34 in array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|string|null}.
Loading history...
33
     */
34 2
    public static function from(array $attributes): self
35
    {
36 2
        return new self(
37 2
            $attributes['attributes']['content_type'],
38 2
            $attributes['attributes']['file_name'],
39 2
            $attributes['attributes']['file_size_bytes'],
40 2
            $attributes['attributes']['file_size_text'],
41 2
            $attributes['attributes']['file_type'],
42 2
            $attributes['attributes']['file_url'],
43 2
            $attributes['id'],
44 2
            $attributes['attributes']['title']
45 2
        );
46
    }
47
}
48