Passed
Branch master (465d67)
by vincent
02:35
created

PeopleMovieCredit::getCast()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 5

Duplication

Lines 11
Ratio 100 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 0
Metric Value
dl 11
loc 11
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 5
nc 3
nop 0
crap 3
1
<?php
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 vfalies\tmdb\Items;
16
17
use vfalies\tmdb\Interfaces\TmdbInterface;
18
use vfalies\tmdb\Abstracts\Item;
19
use vfalies\tmdb\Results\PeopleMovieCast;
20
use vfalies\tmdb\Results\PeopleMovieCrew;
21
22
/**
23
 * People Movie Credit class
24
 * @package Tmdb
25
 * @author Vincent Faliès <[email protected]>
26
 * @copyright Copyright (c) 2017
27
 */
28 View Code Duplication
class PeopleMovieCredit extends Item
0 ignored issues
show
Duplication introduced by
This class 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...
29
{
30
    /**
31
     * Constructor
32
     * @param \vfalies\tmdb\Interfaces\TmdbInterface $tmdb
33
     * @param int $people_id
34
     * @param array $options
35
     */
36 19
    public function __construct(TmdbInterface $tmdb, $people_id, array $options = array())
37
    {
38 19
        parent::__construct($tmdb, '/movie_credits', $options, 'person/' . $people_id);
39 19
    }
40
41
    /**
42
     * Crew
43
     * @return \Generator|Results\Crew
44
     */
45 10
    public function getCrew()
46
    {
47 10
        if (!empty($this->data->crew))
48
        {
49 10
            foreach ($this->data->crew as $c)
50
            {
51 10
                $crew = new PeopleMovieCrew($this->tmdb, $c);
52 10
                yield $crew;
53
            }
54
        }
55 1
    }
56
57
    /**
58
     * Cast
59
     * @return \Generator|Results\Cast
60
     */
61 9
    public function getCast()
62
    {
63 9
        if (!empty($this->data->cast))
64
        {
65 9
            foreach ($this->data->cast as $c)
66
            {
67 9
                $cast = new PeopleMovieCast($this->tmdb, $c);
68 9
                yield $cast;
69
            }
70
        }
71 1
    }
72
}
73