TVEpisodeTrait::getCrew()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 5
nc 3
nop 0
dl 0
loc 8
ccs 6
cts 6
cp 1
crap 3
rs 10
c 0
b 0
f 0
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
12
 */
13
14
15
namespace VfacTmdb\Traits;
16
17
use VfacTmdb\Results;
18
use VfacTmdb\Interfaces\TmdbInterface;
19
20
/**
21
 * TV Episode trait
22
 * @package Tmdb
23
 * @author Vincent Faliès <[email protected]>
24
 * @copyright Copyright (c) 2017
25
 */
26
trait TVEpisodeTrait
27
{
28
    /**
29
     * TVEpisodeTrait object variable
30
     * @var \stdClass
31
     */
32
    protected $tvepisode_trait;
33
34
    /**
35
     * Set TVEpisodeTrait variable
36
     * @param TmdbInterface $tmdb
37
     * @param \stdClass|null $data
38
     * @return void
39
     */
40 141
    protected function setTVEpisodeTrait(TmdbInterface $tmdb, ?\stdClass $data) : void
41
    {
42 141
        $this->tvepisode_trait       = new \stdClass();
43 141
        $this->tvepisode_trait->tmdb = $tmdb;
44 141
        $this->tvepisode_trait->data = $data;
45 141
    }
46
47
    /**
48
     * Get crew of TV Episode
49
     * @return \Generator|Results\Crew
50
     */
51 27
    public function getCrew() : \Generator
52
    {
53 27
        if (!empty($this->tvepisode_trait->data->crew)) {
54 27
            foreach ($this->tvepisode_trait->data->crew as $crew) {
55 27
                $crew->gender = null;
56
57 27
                $return = new Results\Crew($this->tvepisode_trait->tmdb, $crew);
58 27
                yield $return;
59
            }
60
        }
61 6
    }
62
}
63