Passed
Push — develop ( a6f0fe...5308a3 )
by Daniel
24:47 queued 09:44
created

RetrieveResponse   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 16
c 3
b 0
f 0
dl 0
loc 50
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A from() 0 16 1
A __construct() 0 15 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace InShore\Bookwhen\Responses\Events;
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 bool $allDay,
29
        public readonly array $attachments,
30
        public readonly int $attendeeCount,
31
        public readonly int $attendeeLimit,
32
        public readonly string $details,
33
        public readonly string $endAt,
34
        public readonly string $id,
35
        public readonly string $locationId,
36
        public readonly int $maxTicketsPerBooking,
37
        public readonly string $startAt,
38
        public readonly array $tickets,
39
        public readonly string $title,
40
        public readonly bool $waitingList
41
    ) {
42
    }
43
44
    /**
45
     * Acts as static factory, and returns a new Response instance.
46
     *
47
     * @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...
48
     */
49
    public static function from(array $attributes): self
50
    {
51
        return new self(
52
            $attributes['attributes']['all_day'],
53
            $attributes['relationships']['attachments']['data'],
54
            $attributes['attributes']['attendee_count'],
55
            $attributes['attributes']['attendee_limit'],
56
            $attributes['attributes']['details'],
57
            $attributes['attributes']['end_at'],
58
            $attributes['id'],
59
            $attributes['relationships']['location']['data']['id'],
60
            $attributes['attributes']['max_tickets_per_booking'],
61
            $attributes['attributes']['start_at'],
62
            $attributes['relationships']['tickets']['data'],
63
            $attributes['attributes']['title'],
64
            $attributes['attributes']['waiting_list']
65
        );
66
    }
67
}
68