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

Item   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 125
Duplicated Lines 16.8 %

Coupling/Cohesion

Components 1
Dependencies 9

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 9
dl 21
loc 125
ccs 32
cts 32
cp 1
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getMovie() 0 7 1
A getCollection() 0 7 1
A getTVShow() 7 7 1
A getTVSeason() 7 7 1
A getTVEpisode() 7 7 1
A getPeople() 0 7 1
A getCompany() 0 7 1

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 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;
16
17
use VfacTmdb\Items;
18
use VfacTmdb\Interfaces\TmdbInterface;
19
20
/**
21
 * Item class
22
 * @package Tmdb
23
 * @author Vincent Faliès <[email protected]>
24
 * @copyright Copyright (c) 2017
25
 */
26
class Item
27
{
28
    /**
29
     * Tmdb object
30
     * @var TmdbInterface
31
     */
32
    private $tmdb = null;
33
    /**
34
     * Logger object
35
     * @var \Psr\Log\LoggerInterface
36
     */
37
    private $logger = null;
38
39
    /**
40
     * Constructor
41
     * @param TmdbInterface $tmdb
42
     */
43
44 7
    public function __construct(TmdbInterface $tmdb)
45
    {
46 7
        $this->tmdb   = $tmdb;
47 7
        $this->logger = $tmdb->getLogger();
48 7
    }
49
50
    /**
51
     * Get movie details
52
     * @param int $movie_id
53
     * @param array $options
54
     * @return Items\Movie
55
     */
56 1
    public function getMovie(int $movie_id, array $options = array()) : Items\Movie
57
    {
58 1
        $this->logger->debug('Starting getting movie', array('movie_id' => $movie_id, 'options' => $options));
59 1
        $movie = new Items\Movie($this->tmdb, $movie_id, $options);
60
61 1
        return $movie;
62
    }
63
64
    /**
65
     * Get collection details
66
     * @param int $collection_id
67
     * @param array $options
68
     * @return Items\Collection
69
     */
70 1
    public function getCollection(int $collection_id, array $options = array()) : Items\Collection
71
    {
72 1
        $this->logger->debug('Starting getting collection', array('collection_id' => $collection_id, 'options' => $options));
73 1
        $collection = new Items\Collection($this->tmdb, $collection_id, $options);
74
75 1
        return $collection;
76
    }
77
78
    /**
79
     * Get TV Show details
80
     * @param int $tv_id
81
     * @param array $options
82
     * @return Items\TVShow
83
     */
84 1 View Code Duplication
    public function getTVShow(int $tv_id, array $options = array()) : Items\TVShow
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...
85
    {
86 1
        $this->logger->debug('Starting getting tvshow', array('tv_id' => $tv_id, 'options' => $options));
87 1
        $tv = new Items\TVShow($this->tmdb, $tv_id, $options);
88
89 1
        return $tv;
90
    }
91
92
    /**
93
     * Get TV Show episode details
94
     * @param  int    $tv_id
95
     * @param  int    $season_number
96
     * @param  array  $options
97
     * @return Items\TVEpisode
98
     */
99 1 View Code Duplication
    public function getTVSeason(int $tv_id, int $season_number, array $options = array()) : Items\TVSeason
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...
100
    {
101 1
        $this->logger->debug('Starting getting tvseason', array('tv_id' => $tv_id, 'season_number' => $season_number, 'options' => $options));
102 1
        $tvseason = new Items\TVSeason($this->tmdb, $tv_id, $season_number, $options);
103
104 1
        return $tvseason;
105
    }
106
107
    /**
108
     * Get TV Show episode details
109
     * @param  int    $tv_id
110
     * @param  int    $season_number
111
     * @param  int    $episode_number
112
     * @param  array  $options
113
     * @return Items\TVEpisode
114
     */
115 1 View Code Duplication
    public function getTVEpisode(int $tv_id, int $season_number, int $episode_number, array $options = array()) : Items\TVEpisode
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...
116
    {
117 1
        $this->logger->debug('Starting getting tvepisode', array('tv_id' => $tv_id, 'season_number' => $season_number, 'episode_number' => $episode_number, 'options' => $options));
118 1
        $tvepisode = new Items\TVEpisode($this->tmdb, $tv_id, $season_number, $episode_number, $options);
119
120 1
        return $tvepisode;
121
    }
122
123
    /**
124
     * Get People details
125
     * @param int $people_id
126
     * @param array $options
127
     * @return Items\People
128
     */
129 1
    public function getPeople(int $people_id, array $options = array()) : Items\People
130
    {
131 1
        $this->logger->debug('Starting getting people', array('people_id' => $people_id, 'options' => $options));
132 1
        $people = new Items\People($this->tmdb, $people_id, $options);
133
134 1
        return $people;
135
    }
136
137
    /**
138
     * Get Company details
139
     * @param int $company_id
140
     * @param array $options
141
     * @return Items\Company
142
     */
143 1
    public function getCompany(int $company_id, array $options = array()) : Items\Company
144
    {
145 1
        $this->logger->debug('Starting getting company', array('company_id' => $company_id, 'options' => $options));
146 1
        $company = new Items\Company($this->tmdb, $company_id, $options);
147
148 1
        return $company;
149
    }
150
}
151