ScrollableTag::fromAmazonRequest()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 4
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 6
ccs 5
cts 5
cp 1
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MaxBeckers\AmazonAlexa\Request;
6
7
class ScrollableTag
8
{
9
    /**
10
     * @param ScrollDirection|null $direction Scroll direction
11
     * @param bool|null $allowForward Whether forward scrolling is allowed
12
     * @param bool|null $allowBackwards Whether backward scrolling is allowed
13
     */
14 3
    public function __construct(
15
        public ?ScrollDirection $direction = null,
16
        public ?bool $allowForward = null,
17
        public ?bool $allowBackwards = null,
18
    ) {
19 3
    }
20
21 3
    public static function fromAmazonRequest(array $amazonRequest): self
22
    {
23 3
        return new self(
24 3
            direction: isset($amazonRequest['direction']) ? ScrollDirection::tryFrom($amazonRequest['direction']) : null,
25 3
            allowForward: $amazonRequest['allowForward'] ?? null,
26 3
            allowBackwards: $amazonRequest['allowBackwards'] ?? null,
27 3
        );
28
    }
29
}
30