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

Permission::getIcon()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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