ScrollableTag::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 0
c 1
b 0
f 1
nc 1
nop 3
dl 0
loc 5
ccs 1
cts 1
cp 1
crap 1
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