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

RetrieveResponse   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A from() 0 17 1
A __construct() 0 17 1
A toArray() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace InShore\Bookwhen\Responses\Tickets;
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
28
29
30
    'cost' =>
31
    array (
32
      'currency_code' => 'GBP',
33
      'net' => 3500,
34
      'tax' => 0,
35
    ),
36
     */
37
    private function __construct(
38
        public readonly bool $available,
39
        public readonly null | string $availableFrom,
40
        public readonly null | string $availableTo,
41
        public readonly string $builtBasketUrl,
42
        public readonly string $builtBasketIframeUrl,
43
        public readonly bool $courseTicket,
44
        // cost
45
        public readonly string $details,
46
        public readonly bool $groupTicket,
47
        public readonly int $groupMin,
48
        public readonly int $groupMax,
49
        public readonly string $id,
50
        public readonly int | null $numberIssued,
51
        public readonly int $numberTaken,
52
        public readonly string $title
53
    ) {
54
    }
55
56
    /**
57
     * Acts as static factory, and returns a new Response instance.
58
     *
59
     * @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...
60
     */
61
    public static function from(array $attributes): self
62
    {
63
        return new self(
64
            $attributes['attributes']['available'],
65
            $attributes['attributes']['available_from'],
66
            $attributes['attributes']['available_to'],
67
            $attributes['attributes']['built_basket_url'],
68
            $attributes['attributes']['built_basket_iframe_url'],
69
            $attributes['attributes']['course_ticket'],
70
            $attributes['attributes']['details'],
71
            $attributes['attributes']['group_ticket'],
72
            $attributes['attributes']['group_min'],
73
            $attributes['attributes']['group_max'],
74
            $attributes['id'],
75
            $attributes['attributes']['number_issued'],
76
            $attributes['attributes']['number_taken'],
77
            $attributes['attributes']['title']
78
        );
79
    }
80
81
    /**
82
     * {@inheritDoc}
83
     */
84
    public function toArray(): array
85
    {
86
        return [
87
            'id' => $this->id,
88
            'type' => $this->type,
0 ignored issues
show
Bug Best Practice introduced by
The property type does not exist on InShore\Bookwhen\Respons...ickets\RetrieveResponse. Did you maybe forget to declare it?
Loading history...
89
            //'attributes' => $this->attributes,
90
        ];
91
    }
92
}
93