ListResponse::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 0
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
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
use InShore\Bookwhen\Responses\Locations\RetrieveResponse;
9
10
/**
11
 * @implements ResponseContract<array{object: string, data: array<int, array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|string|null}>}>
12
 */
13
final class ListResponse implements ResponseContract
14
{
15
    /**
16
     * @param  array<int, RetrieveResponse>  $data
17
     */
18 1
    private function __construct(
19
        public readonly array $data,
20
    ) {
21 1
    }
22
23
    /**
24
     * Acts as static factory, and returns a new Response instance.
25
     *
26
     * @param  array{data: array<int, array{event_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{data: array<int, a..., mixed>|string|null}>} at position 42 could not be parsed: Unknown type name 'array-key' at position 42 in array{data: array<int, array{event_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...
27
     */
28 1
    public static function from(array $attributes): self
29
    {
30
31 1
        $data = array_map(fn (array $result): RetrieveResponse => RetrieveResponse::from(
32 1
            $result
33 1
        ), $attributes['data']);
34
35 1
        return new self(
36 1
            $data,
37 1
        );
38
    }
39
}
40