RetrieveResponse   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 10
dl 0
loc 39
ccs 11
cts 11
cp 1
rs 10
c 2
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A from() 0 11 1
A __construct() 0 9 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace InShore\Bookwhen\Responses\ClassPasses;
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 4
    private function __construct(
28
        public readonly null | string $details,
29
        public readonly string $id,
30
        public readonly int | null $numberAvailable,
31
        public readonly null | string $title,
32
        public readonly int | null $usageAllowance,
33
        public readonly null | string $usageType,
34
        public readonly int | null $useRestrictedForDays,
35
    ) {
36 4
    }
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 4
    public static function from(array $attributes): self
44
    {
45
46 4
        return new self(
47 4
            $attributes['attributes']['details'],
48 4
            $attributes['id'],
49 4
            $attributes['attributes']['number_available'],
50 4
            $attributes['attributes']['title'],
51 4
            $attributes['attributes']['usage_allowance'],
52 4
            $attributes['attributes']['usage_type'],
53 4
            $attributes['attributes']['use_restricted_for_days'],
54 4
        );
55
    }
56
}
57