Passed
Pull Request — develop (#95)
by
unknown
29:42 queued 14:41
created

RetrieveResponse::toArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
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
use InShore\Bookwhen\Responses\Concerns\ArrayAccessible;
9
10
//use OpenAI\Testing\Responses\Concerns\Fakeable;
11
12
/**
13
 * @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}>
14
 */
15
final class RetrieveResponse implements ResponseContract
16
{
17
    /**
18
     * @use ArrayAccessible<array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|string|null}>
19
     */
20
    use ArrayAccessible;
21
22
    //use Fakeable;
23
24
    /**
25
     * @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...
26
     */
27
    private function __construct(
28
        public readonly null | string $addressText,
29
        public readonly null | string $additionalInfo,
30
        public readonly string $id,
31
        public readonly float | null $latitude,
32
        public readonly float | null $longitude,
33
        public readonly null | string $mapUrl,
34
        public readonly int | null $zoom
35
    ) {
36
    }
37
38
    /**
39
     * Acts as static factory, and returns a new Response instance.
40
     *
41
     * @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...
42
     */
43
    public static function from(array $attributes): self
44
    {
45
        return new self(
46
            $attributes['attributes']['address_text'],
47
            $attributes['attributes']['additional_info'],
48
            $attributes['id'],
49
            $attributes['attributes']['latitude'],
50
            $attributes['attributes']['longitude'],
51
            $attributes['attributes']['map_url'],
52
            $attributes['attributes']['zoom']
53
        );
54
    }
55
}
56