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

RetrieveResponse   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 39
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 5 1
A __construct() 0 4 1
A from() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace InShore\Bookwhen\Responses\Attachments;
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 string $id,
29
        public readonly string $title
30
    ) {
31
    }
32
33
    /**
34
     * Acts as static factory, and returns a new Response instance.
35
     *
36
     * @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...
37
     */
38
    public static function from(array $attributes): self
39
    {
40
        return new self(
41
            $attributes['id'],
42
            $attributes['attributes']['title']
43
        );
44
    }
45
46
    /**
47
     * {@inheritDoc}
48
     */
49
    public function toArray(): array
50
    {
51
        return [
52
            'id' => $this->id,
53
            'type' => $this->type,
0 ignored issues
show
Bug Best Practice introduced by
The property type does not exist on InShore\Bookwhen\Respons...hments\RetrieveResponse. Did you maybe forget to declare it?
Loading history...
54
            //'attributes' => $this->attributes,
55
        ];
56
    }
57
}
58