Permission   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Test Coverage

Coverage 28.57%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 15
c 1
b 0
f 0
dl 0
loc 62
ccs 4
cts 14
cp 0.2857
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getIcon() 0 3 1
A __construct() 0 5 1
A getLabel() 0 3 1
A getPermissions() 0 3 1
A asArray() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * Copyright (c) Ne-Lexa
7
 *
8
 * For the full copyright and license information, please view
9
 * the LICENSE file that was distributed with this source code.
10
 *
11
 * @see https://github.com/Ne-Lexa/google-play-scraper
12
 */
13
14
namespace Nelexa\GPlay\Model;
15
16
/**
17
 * Contains information about application permissions.
18
 */
19
class Permission implements \JsonSerializable
20
{
21
    use JsonSerializableTrait;
22
23
    /** @var string Permission label. */
24
    private $label;
25
26
    /** @var GoogleImage */
27
    private $icon;
28
29
    /** @var string[] Permissions. */
30
    private $permissions;
31
32
    /**
33
     * Permission constructor.
34
     *
35
     * @param string      $label
36
     * @param GoogleImage $icon
37
     * @param string[]    $permissions
38
     */
39 1
    public function __construct(string $label, GoogleImage $icon, array $permissions)
40
    {
41 1
        $this->label = $label;
42 1
        $this->icon = $icon;
43 1
        $this->permissions = $permissions;
44
    }
45
46
    /**
47
     * @return string
48
     */
49
    public function getLabel(): string
50
    {
51
        return $this->label;
52
    }
53
54
    /**
55
     * @return GoogleImage
56
     */
57
    public function getIcon(): GoogleImage
58
    {
59
        return $this->icon;
60
    }
61
62
    /**
63
     * @return string[]
64
     */
65
    public function getPermissions(): array
66
    {
67
        return $this->permissions;
68
    }
69
70
    /**
71
     * Returns class properties as an array.
72
     *
73
     * @return array class properties as an array
74
     */
75
    public function asArray(): array
76
    {
77
        return [
78
            'label' => $this->label,
79
            'icon' => $this->icon->getUrl(),
80
            'permissions' => $this->permissions,
81
        ];
82
    }
83
}
84