Passed
Push — master ( 585494...856ecb )
by vincent
03:23 queued 12s
created

TVShowCredit::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
nc 1
nop 3
dl 0
loc 6
rs 10
c 1
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-2021
12
 */
13
14
15
namespace VfacTmdb\Items;
16
17
use VfacTmdb\Results;
18
use VfacTmdb\Interfaces\TmdbInterface;
19
20
/**
21
 * TVShow Credit class
22
 * @package Tmdb
23
 * @author Vincent Faliès <[email protected]>
24
 * @copyright Copyright (c) 2017-2021
25
 */
26
class TVShowCredit
27
{
28
    /**
29
     * Tmdb object
30
     * @var TmdbInterface
31
     */
32
    private $tmdb = null;
33
    /**
34
     * Logger object
35
     * @var \Psr\Log\LoggerInterface
36
     */
37
    protected $logger = null;
38
    /**
39
     * Params
40
     * @var array
41
     */
42
    protected $params = null;
43
    /**
44
     * Data
45
     * @var \stdClass
46
     */
47
    protected $data = null;
48
    /**
49
     * Crew
50
     * @var \stdClass
51
     */
52
    protected $crew;
53
    /**
54
     * Options array
55
     * @var array
56
     */
57
    protected $options;
58
59
    /**
60
     * Constructor
61
     * @param TmdbInterface $tmdb
62
     * @param int $tvshow_id
63
     * @param array $options
64
     */
65
    public function __construct(TmdbInterface $tmdb, int $tvshow_id, array $options = array())
66
    {
67
        $this->tmdb    = $tmdb;
68
        $this->logger  = $tmdb->getLogger();
69
        $this->data    = $this->tmdb->getRequest('tv/' . $tvshow_id . '/credits');
70
        $this->options = $options;
71
    }
72
73
    /**
74
     * Crew
75
     * @return \Generator|Results\Crew
76
     */
77
    public function getCrew() : \Generator
78
    {
79
        foreach ($this->data->crew as $c) {
80
            $crew = new Results\Crew($this->tmdb, $c);
81
            yield $crew;
82
        }
83
    }
84
85
    /**
86
     * Cast
87
     * @return \Generator|Results\Cast
88
     */
89
    public function getCast() : \Generator
90
    {
91
        foreach ($this->data->cast as $c) {
92
            $cast = new Results\Cast($this->tmdb, $c);
93
            yield $cast;
94
        }
95
    }
96
}
97