Completed
Pull Request — master (#30)
by vincent
03:53
created

MovieCredit::getCast()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 5

Duplication

Lines 9
Ratio 100 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 0
Metric Value
dl 9
loc 9
ccs 6
cts 6
cp 1
rs 9.6666
c 0
b 0
f 0
cc 3
eloc 5
nc 3
nop 0
crap 3
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\Items;
16
17
use VfacTmdb\Results;
18
use VfacTmdb\Interfaces\TmdbInterface;
19
20
/**
21
 * Movie Credit class
22
 * @package Tmdb
23
 * @author Vincent Faliès <[email protected]>
24
 * @copyright Copyright (c) 2017
25
 */
26
class MovieCredit
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 $movie_id
63
     * @param array $options
64
     */
65 10
    public function __construct(TmdbInterface $tmdb, int $movie_id, array $options = array())
66
    {
67 10
        $this->tmdb    = $tmdb;
68 10
        $this->logger  = $tmdb->getLogger();
69 10
        $this->data    = $this->tmdb->getRequest('movie/' . $movie_id . '/credits');
70 10
        $this->options = $options;
71 10
    }
72
73
    /**
74
     * Crew
75
     * @return \Generator|Results\Crew
76
     */
77 1 View Code Duplication
    public function getCrew() : \Generator
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
78
    {
79 1
        if (!empty($this->data->crew)) {
80 1
            foreach ($this->data->crew as $c) {
81 1
                $crew = new Results\Crew($this->tmdb, $c);
82 1
                yield $crew;
83
            }
84
        }
85 1
    }
86
87
    /**
88
     * Cast
89
     * @return \Generator|Results\Cast
90
     */
91 9 View Code Duplication
    public function getCast() : \Generator
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
92
    {
93 9
        if (!empty($this->data->cast)) {
94 9
            foreach ($this->data->cast as $c) {
95 9
                $cast = new Results\Cast($this->tmdb, $c);
96 9
                yield $cast;
97
            }
98
        }
99 1
    }
100
}
101