SelfDescription::createFromArray()   A
last analyzed

Complexity

Conditions 4
Paths 8

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.2
c 0
b 0
f 0
cc 4
eloc 5
nc 8
nop 1
1
<?php
2
3
namespace Happyr\ApiClient\Model\Match;
4
5
use Happyr\ApiClient\Model\CreatableFromArray;
6
7
/**
8
 * @author Tobias Nyholm <[email protected]>
9
 */
10
final class SelfDescription implements CreatableFromArray
11
{
12
    /**
13
     * @var array
14
     */
15
    private $profiles;
16
17
    /**
18
     * @var array
19
     */
20
    private $strongDescription;
21
22
    /**
23
     * @var array
24
     */
25
    private $weakDescription;
26
27
    /**
28
     * @param array $profiles
29
     * @param array $strongDescription
30
     * @param array $weakDescription
31
     */
32
    public function __construct(array $profiles, array $strongDescription, array $weakDescription)
33
    {
34
        $this->profiles = $profiles;
35
        $this->strongDescription = $strongDescription;
36
        $this->weakDescription = $weakDescription;
37
    }
38
39
    /**
40
     * @param array $data
41
     *
42
     * @return
43
     */
44
    public static function createFromArray(array $data)
45
    {
46
        $profiles = isset($data['data']['profiles']) ? $data['data']['profiles'] : [];
47
        $strong = isset($data['data']['description']['strong']) ? $data['data']['description']['strong'] : [];
48
        $week = isset($data['data']['description']['weak']) ? $data['data']['description']['weak'] : [];
49
50
        return new self($profiles, $strong, $week);
51
    }
52
53
    /**
54
     * @return array
55
     */
56
    public function getProfiles()
57
    {
58
        return $this->profiles;
59
    }
60
61
    /**
62
     * @return array
63
     */
64
    public function getStrongDescription()
65
    {
66
        return $this->strongDescription;
67
    }
68
69
    /**
70
     * @return array
71
     */
72
    public function getWeakDescription()
73
    {
74
        return $this->weakDescription;
75
    }
76
}
77