RetrieveResponse::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 0
c 2
b 0
f 0
nc 1
nop 7
dl 0
loc 9
ccs 1
cts 1
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace InShore\Bookwhen\Responses\Locations;
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 8
    private function __construct(
18
        public readonly null | string $additionalInfo,
19
        public readonly null | string $addressText,
20
        public readonly string $id,
21
        public readonly float | null $latitude,
22
        public readonly float | null $longitude,
23
        public readonly null | string $mapUrl,
24
        public readonly int | null $zoom
25
    ) {
26 8
    }
27
28
    /**
29
     * Acts as static factory, and returns a new Response instance.
30
     *
31
     * @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...
32
     */
33 8
    public static function from(array $attributes): self
34
    {
35 8
        return new self(
36 8
            $attributes['attributes']['additional_info'] ?? null,
37 8
            $attributes['attributes']['address_text'] ?? null,
38 8
            $attributes['id'],
39 8
            $attributes['attributes']['latitude'] ?? null,
40 8
            $attributes['attributes']['longitude'] ?? null,
41 8
            $attributes['attributes']['map_url'] ?? null,
42 8
            $attributes['attributes']['zoom'] ?? null
43 8
        );
44
    }
45
}
46