RuntimeError   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 8
dl 0
loc 29
ccs 10
cts 10
cp 1
rs 10
c 1
b 0
f 1
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fromAmazonRequest() 0 9 2
A __construct() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MaxBeckers\AmazonAlexa\Request\Request\APL;
6
7
use MaxBeckers\AmazonAlexa\Helper\PropertyHelper;
8
9
class RuntimeError
10
{
11
    /**
12
     * @param RuntimeErrorType|null $type Error type
13
     * @param string|null $reason Error reason
14
     * @param string|null $listId List identifier where error occurred
15
     * @param int|null $listVersion List version when error occurred
16
     * @param int|null $operationIndex Index of the operation that caused the error
17
     * @param string|null $message Error message
18
     */
19 2
    public function __construct(
20
        public ?RuntimeErrorType $type = null,
21
        public ?string $reason = null,
22
        public ?string $listId = null,
23
        public ?int $listVersion = null,
24
        public ?int $operationIndex = null,
25
        public ?string $message = null,
26
    ) {
27 2
    }
28
29 2
    public static function fromAmazonRequest(array $amazonRequest): self
30
    {
31 2
        return new self(
32 2
            type: isset($amazonRequest['type']) ? RuntimeErrorType::tryFrom($amazonRequest['type']) : null,
33 2
            reason: PropertyHelper::checkNullValueString($amazonRequest, 'reason'),
34 2
            listId: PropertyHelper::checkNullValueString($amazonRequest, 'listId'),
35 2
            listVersion: PropertyHelper::checkNullValueInt($amazonRequest, 'listVersion'),
36 2
            operationIndex: PropertyHelper::checkNullValueInt($amazonRequest, 'operationIndex'),
37 2
            message: PropertyHelper::checkNullValueString($amazonRequest, 'message'),
38 2
        );
39
    }
40
}
41