SkillPermissionBody   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A fromAmazonRequest() 0 12 4
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MaxBeckers\AmazonAlexa\Request\Request\AlexaSkillEvent;
6
7
class SkillPermissionBody
8
{
9
    /**
10
     * @param Permission[] $acceptedPermissions Array of accepted permissions
11
     */
12 2
    public function __construct(
13
        public array $acceptedPermissions = [],
14
    ) {
15 2
    }
16
17 2
    public static function fromAmazonRequest(array $amazonRequest): self
18
    {
19 2
        $acceptedPermissions = [];
20
21 2
        if (isset($amazonRequest['acceptedPermissions']) && is_array($amazonRequest['acceptedPermissions'])) {
22 2
            foreach ($amazonRequest['acceptedPermissions'] as $permission) {
23 2
                $acceptedPermissions[] = Permission::fromAmazonRequest($permission);
24
            }
25
        }
26
27 2
        return new self(
28 2
            acceptedPermissions: $acceptedPermissions,
29 2
        );
30
    }
31
}
32