Passed
Push — master ( 2df3e9...783a15 )
by vincent
02:39 queued 10s
created

Find::getTVEpisodes()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 2
rs 10
1
<?php declare(strict_types=1);
2
/**
3
 * This file is part of the Tmdb package.
4
 *
5
 * (c) Vincent Faliès <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @author Vincent Faliès <[email protected]>
11
 * @copyright Copyright (c) 2017-2020
12
 */
13
14
15
namespace VfacTmdb\Results;
16
17
use VfacTmdb\Abstracts;
18
use VfacTmdb\Interfaces\TmdbInterface;
19
use VfacTmdb\Results;
20
21
/**
22
 * Class to manipulate find results
23
 * @package Tmdb
24
 * @author Vincent Faliès <[email protected]>
25
 * @copyright Copyright (c) 2017-2020
26
 */
27
class Find extends Abstracts\Results
28
{
29
    /**
30
     * Id
31
     * @var int
32
     */
33
    protected $id;
34
    /**
35
     * Movie results
36
     * @var array
37
     */
38
    protected $movie_results;
39
    /**
40
     * Person results
41
     * @var array
42
     */
43
    protected $person_results;
44
    /**
45
     * TV results
46
     *
47
     * @var array
48
     */
49
    protected $tv_results;
50
    /**
51
     * TV episode results
52
     *
53
     * @var array
54
     */
55
    protected $tv_episode_results;
56
    /**
57
     * TV season results
58
     *
59
     * @var array
60
     */
61
    protected $tv_season_results;
62
63
    /**
64
     * Constructor
65
     * @param TmdbInterface $tmdb
66
     * @param int $id
67
     * @param \stdClass $result
68
     */
69 54
    public function __construct(TmdbInterface $tmdb, \stdClass $result)
70
    {
71 54
        $result->id = 0;
72
73 54
        parent::__construct($tmdb, $result);
74
75 51
        $this->id                 = $result->id;
76 51
        $this->movie_results      = $result->movie_results;
77 51
        $this->person_results     = $result->person_results;
78 51
        $this->tv_results         = $result->tv_results;
79 51
        $this->tv_episode_results = $result->tv_episode_results;
80 51
        $this->tv_season_results  = $result->tv_season_results;
81 51
    }
82
83
    /**
84
     * Id
85
     * @return int
86
     */
87 3
    public function getId() : int
88
    {
89 3
        return $this->id;
90
    }
91
92
    /**
93
     * Get movies
94
     *
95
     * @return \Generator|Results\Movie
96
     */
97 21
    public function getMovies() : \Generator
98
    {
99 21
        foreach ($this->movie_results as $movie) {
100 15
            yield new Results\Movie($this->tmdb, $movie);
101
        }
102 6
    }
103
104
    /**
105
     * Get peoples
106
     *
107
     * @return \Generator|Results\People
108
     */
109 9
    public function getPeoples() : \Generator
110
    {
111 9
        foreach ($this->person_results as $person) {
112 6
            yield new Results\People($this->tmdb, $person);
113
        }
114 3
    }
115
116
    /**
117
     * Get TV shows
118
     *
119
     * @return \Generator|Results\TVShow
120
     */
121 6
    public function getTVShows() : \Generator
122
    {
123 6
        foreach ($this->tv_results as $tvshow) {
124 3
            yield new Results\TVShow($this->tmdb, $tvshow);
125
        }
126 3
    }
127
128
    /**
129
     * Get TV episodes
130
     *
131
     * @return \Generator|Results\TVEpisode
132
     */
133 6
    public function getTVEpisodes() : \Generator
134
    {
135 6
        foreach ($this->tv_episode_results as $tvepisode) {
136 3
            yield new Results\TVEpisode($this->tmdb, $tvepisode);
137
        }
138 3
    }
139
140
    /**
141
     * Get TV seasons
142
     *
143
     * @return \Generator|Results\TVSeason
144
     */
145 6
    public function getTVSeasons() : \Generator
146
    {
147 6
        foreach ($this->tv_season_results as $tvseason) {
148 3
            yield new Results\TVSeason($this->tmdb, $tvseason);
149
        }
150 3
    }
151
}
152