Passed
Branch release/1.5.0 (d52397)
by vincent
02:35
created

People::getProfiles()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 0
crap 2
1
<?php
2
3
namespace vfalies\tmdb\Items;
4
5
use vfalies\tmdb\Abstracts\Item;
6
use vfalies\tmdb\Interfaces\PeopleInterface;
7
use vfalies\tmdb\Tmdb;
8
use vfalies\tmdb\Traits\ElementTrait;
9
use vfalies\tmdb\lib\Guzzle\Client as HttpClient;
10
use vfalies\tmdb\Results\Image;
11
12
class People extends Item implements PeopleInterface
13
{
14
15
    use ElementTrait;
16
17
    /**
18
     * Constructor
19
     * @param \vfalies\tmdb\Tmdb $tmdb
20
     * @param int $people_id
21
     * @param array $options
22
     * @throws Exception
23
     */
24 29
    public function __construct(Tmdb $tmdb, $people_id, array $options = array())
25
    {
26 29
        parent::__construct($tmdb, $people_id, $options, 'people');
27 28
    }
28
29 2
    public function getAdult()
30
    {
31 2
        if (isset($this->data->adult))
32
        {
33 1
            return $this->data->adult;
34
        }
35 1
        return false;
36
    }
37
38 2
    public function getAlsoKnownAs()
39
    {
40 2
        if (isset($this->data->also_known_as))
41
        {
42 1
            return $this->data->also_known_as;
43
        }
44 1
        return [];
45
    }
46
47 2
    public function getBiography()
48
    {
49 2
        if (isset($this->data->biography))
50
        {
51 1
            return $this->data->biography;
52
        }
53 1
        return '';
54
    }
55
56 2
    public function getBirthday()
57
    {
58 2
        if (isset($this->data->birthday))
59
        {
60 1
            return $this->data->birthday;
61
        }
62 1
        return '';
63
    }
64
65 2
    public function getDeathday()
66
    {
67 2
        if (isset($this->data->deathday))
68
        {
69 1
            return $this->data->deathday;
70
        }
71 1
        return '';
72
    }
73
74 2
    public function getGender()
75
    {
76 2
        if (isset($this->data->gender))
77
        {
78 1
            return $this->data->gender;
79
        }
80 1
        return 0;
81
    }
82
83 2
    public function getHomepage()
84
    {
85 2
        if (isset($this->data->homepage))
86
        {
87 1
            return $this->data->homepage;
88
        }
89 1
        return '';
90
    }
91
92 3
    public function getId()
93
    {
94 3
        if (isset($this->data->id))
95
        {
96 2
            return $this->data->id;
97
        }
98 1
        return 0;
99
    }
100
101 2
    public function getImdbId()
102
    {
103 2
        if (isset($this->data->imdb_id))
104
        {
105 1
            return $this->data->imdb_id;
106
        }
107 1
        return '';
108
    }
109
110 2
    public function getName()
111
    {
112 2
        if (isset($this->data->name))
113
        {
114 1
            return $this->data->name;
115
        }
116 1
        return '';
117
    }
118
119 2
    public function getPlaceOfBirth()
120
    {
121 2
        if (isset($this->data->place_of_birth))
122
        {
123 1
            return $this->data->place_of_birth;
124
        }
125 1
        return '';
126
    }
127
128 2
    public function getPopularity()
129
    {
130 2
        if (isset($this->data->popularity))
131
        {
132 1
            return $this->data->popularity;
133
        }
134 1
        return 0;
135
    }
136
137 2
    public function getProfilePath()
138
    {
139 2
        if (isset($this->data->profile_path))
140
        {
141 1
            return $this->data->profile_path;
142
        }
143 1
        return '';
144
    }
145
146 1
    public function getProfiles()
147
    {
148 1
        $data = $this->tmdb->sendRequest(new HttpClient(new \GuzzleHttp\Client()), '/person/'.(int) $this->id.'/images', null, $this->params);
149
150 1
        foreach ($data->profiles as $b)
151
        {
152 1
            $image = new Image($this->tmdb, $this->id, $b);
153 1
            yield $image;
154
        }
155 1
    }
156
}
157