Interview   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 80
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 0
dl 0
loc 80
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A createFromArray() 0 7 3
A toArray() 0 8 1
A getProfiles() 0 4 1
A getDescription() 0 4 1
A isComplete() 0 4 1
1
<?php
2
3
namespace Happyr\ApiClient\Model\Interview;
4
5
use Happyr\ApiClient\Model\CreatableFromArray;
6
7
/**
8
 * @author Tobias Nyholm <[email protected]>
9
 */
10
final class Interview implements CreatableFromArray
11
{
12
    /**
13
     * @var array with keys as profile ids and each profile has a name, statements and questions
14
     */
15
    private $profiles;
16
17
    /**
18
     * @var string
19
     */
20
    private $description;
21
22
    /**
23
     * @var bool
24
     */
25
    private $complete;
26
27
    /**
28
     * @param array  $profiles
29
     * @param string $description
30
     * @param bool   $complete
31
     */
32
    private function __construct(array $profiles, $description, $complete)
33
    {
34
        $this->profiles = $profiles;
35
        $this->description = $description;
36
        $this->complete = $complete;
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
        $description = isset($data['data']['description']) ? $data['data']['description'] : '';
48
49
        return new self($profiles, $description, $data['data']['complete']);
50
    }
51
52
    /**
53
     * This is allow legacy code use the interview object.
54
     *
55
     * @return array
56
     */
57
    public function toArray()
58
    {
59
        return [
60
            'profiles' => $this->profiles,
61
            'description' => $this->description,
62
            'complete' => $this->complete,
63
        ];
64
    }
65
66
    /**
67
     * @return array
68
     */
69
    public function getProfiles()
70
    {
71
        return $this->profiles;
72
    }
73
74
    /**
75
     * @return string
76
     */
77
    public function getDescription()
78
    {
79
        return $this->description;
80
    }
81
82
    /**
83
     * @return bool
84
     */
85
    public function isComplete()
86
    {
87
        return $this->complete;
88
    }
89
}
90