RetrieveResponse   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 5
Bugs 0 Features 0
Metric Value
eloc 22
c 5
b 0
f 0
dl 0
loc 55
ccs 24
cts 24
cp 1
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 17 1
A from() 0 26 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace InShore\Bookwhen\Responses\Tickets;
6
7
use InShore\Bookwhen\Contracts\ResponseContract;
8
9
/**
10
 * @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}>
11
 */
12
final class RetrieveResponse implements ResponseContract
13
{
14
    /**
15
     * @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...
16
     */
17 8
    private function __construct(
18
        public readonly bool | null $available,
19
        public readonly null | string $availableFrom,
20
        public readonly null | string $availableTo,
21
        public readonly null | string $builtBasketUrl,
22
        public readonly null | string $builtBasketIframeUrl,
23
        public readonly object $cost,
24
        public readonly bool | null $courseTicket,
25
        public readonly null | string $details,
26
        public readonly bool | null $groupTicket,
27
        public readonly int | null $groupMin,
28
        public readonly int | null $groupMax,
29
        public readonly string $id,
30
        public readonly int | null $numberIssued,
31
        public readonly int | null $numberTaken,
32
        public readonly null | string $title
33
    ) {
34 8
    }
35
36
    /**
37
     * Acts as static factory, and returns a new Response instance.
38
     *
39
     * @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...
40
     */
41 8
    public static function from(array $attributes, $included = []): self
0 ignored issues
show
Unused Code introduced by
The parameter $included is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

41
    public static function from(array $attributes, /** @scrutinizer ignore-unused */ $included = []): self

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
42
    {
43
44 8
        $cost = new \stdClass();
45 8
        if (!empty($attributes['attributes']['cost'])) {
46 2
            $cost->currencyCode = $attributes['attributes']['cost']['currency_code'];
47 2
            $cost->net = $attributes['attributes']['cost']['net'];
48 2
            $cost->tax = $attributes['attributes']['cost']['tax'];
49
        }
50
51 8
        return new self(
52 8
            $attributes['attributes']['available'] ?? null,
53 8
            $attributes['attributes']['available_from'] ?? null,
54 8
            $attributes['attributes']['available_to'] ?? null,
55 8
            $attributes['attributes']['built_basket_url'] ?? null,
56 8
            $attributes['attributes']['built_basket_iframe_url'] ?? null,
57 8
            $cost,
58 8
            $attributes['attributes']['course_ticket'] ?? null,
59 8
            $attributes['attributes']['details'] ?? null,
60 8
            $attributes['attributes']['group_ticket'] ?? null,
61 8
            $attributes['attributes']['group_min'] ?? null,
62 8
            $attributes['attributes']['group_max'] ?? null,
63 8
            $attributes['id'],
64 8
            $attributes['attributes']['number_issued'] ?? null,
65 8
            $attributes['attributes']['number_taken'] ?? null,
66 8
            $attributes['attributes']['title'] ?? null,
67 8
        );
68
    }
69
}
70