Passed
Branch release/1.5.0 (5f009d)
by vincent
05:05
created

PeopleMovieCredit   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 45
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 3
dl 45
loc 45
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A getCrew() 11 11 3
A getCast() 11 11 3

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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
11
 * @author Vincent Faliès <[email protected]>
12
 * @copyright Copyright (c) 2017
13
 */
14
15
16
namespace vfalies\tmdb\Items;
17
18
use vfalies\tmdb\Interfaces\TmdbInterface;
19
use vfalies\tmdb\Abstracts\Item;
20
use vfalies\tmdb\Results\PeopleMovieCast;
21
use vfalies\tmdb\Results\PeopleMovieCrew;
22
23
/**
24
 * People Movie Credit class
25
 * @package Tmdb
26
 * @author Vincent Faliès <[email protected]>
27
 * @copyright Copyright (c) 2017
28
 */
29 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...
30
{
31
    /**
32
     * Constructor
33
     * @param \vfalies\tmdb\Interfaces\TmdbInterface $tmdb
34
     * @param int $people_id
35
     * @param array $options
36
     */
37 19
    public function __construct(TmdbInterface $tmdb, $people_id, array $options = array())
38
    {
39 19
        parent::__construct($tmdb, '/movie_credits', $options, 'person/'.$people_id);
40 19
    }
41
42
    /**
43
     * Crew
44
     * @return \Generator|Results\Crew
45
     */
46 10
    public function getCrew()
47
    {
48 10
        if (!empty($this->data->crew))
49
        {
50 10
            foreach ($this->data->crew as $c)
51
            {
52 10
                $crew = new PeopleMovieCrew($this->tmdb, $c);
53 10
                yield $crew;
54
            }
55
        }
56 1
    }
57
58
    /**
59
     * Cast
60
     * @return \Generator|Results\Cast
61
     */
62 9
    public function getCast()
63
    {
64 9
        if (!empty($this->data->cast))
65
        {
66 9
            foreach ($this->data->cast as $c)
67
            {
68 9
                $cast = new PeopleMovieCast($this->tmdb, $c);
69 9
                yield $cast;
70
            }
71
        }
72
    }
73
}