Passed
Branch feature/refactoring (13cbf0)
by Alexey
03:46
created

Permission   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Test Coverage

Coverage 33.33%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 15
c 1
b 0
f 0
dl 0
loc 62
ccs 5
cts 15
cp 0.3333
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
 * @author   Ne-Lexa
7
 * @license  MIT
8
 *
9
 * @see      https://github.com/Ne-Lexa/google-play-scraper
10
 */
11
12
namespace Nelexa\GPlay\Model;
13
14
/**
15
 * Contains information about application permissions.
16
 */
17
class Permission implements \JsonSerializable
18
{
19
    use JsonSerializableTrait;
20
21
    /** @var string Permission label. */
22
    private $label;
23
24
    /** @var GoogleImage */
25
    private $icon;
26
27
    /** @var string[] Permissions. */
28
    private $permissions;
29
30
    /**
31
     * Permission constructor.
32
     *
33
     * @param string      $label
34
     * @param GoogleImage $icon
35
     * @param string[]    $permissions
36
     */
37 1
    public function __construct(string $label, GoogleImage $icon, array $permissions)
38
    {
39 1
        $this->label = $label;
40 1
        $this->icon = $icon;
41 1
        $this->permissions = $permissions;
42 1
    }
43
44
    /**
45
     * @return string
46
     */
47
    public function getLabel(): string
48
    {
49
        return $this->label;
50
    }
51
52
    /**
53
     * @return GoogleImage
54
     */
55
    public function getIcon(): GoogleImage
56
    {
57
        return $this->icon;
58
    }
59
60
    /**
61
     * @return string[]
62
     */
63
    public function getPermissions(): array
64
    {
65
        return $this->permissions;
66
    }
67
68
    /**
69
     * Returns class properties as an array.
70
     *
71
     * @return array class properties as an array
72
     */
73
    public function asArray(): array
74
    {
75
        return [
76
            'label' => $this->label,
77
            'icon' => $this->icon->getUrl(),
78
            'permissions' => $this->permissions,
79
        ];
80
    }
81
}
82