Completed
Branch account (edf133)
by vincent
02:17
created

WatchList   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 62
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 62
loc 62
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getMovies() 4 4 1
A getTVShows() 4 4 1
A addMovie() 4 4 1
A removeMovie() 4 4 1
A addTVShow() 4 4 1
A removeTVShow() 4 4 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\Account;
16
17
use VfacTmdb\Results;
18
use VfacTmdb\Traits\ListItems;
19
use VfacTmdb\Abstracts\Account;
20
21
/**
22
 * Class to manipulate account watchlist
23
 * @package Tmdb
24
 * @author Vincent Faliès <[email protected]>
25
 * @copyright Copyright (c) 2017
26
 */
27 View Code Duplication
class WatchList extends Account
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...
28
{
29
    use ListItems;
30
31
    /**
32
     * Get movies watchlist
33
     * @return \Generator|Results\Movie
34
     */
35 1
    public function getMovies() : \Generator
36
    {
37 1
        return $this->getAccountListItems('watchlist', 'movies', Results\Movie::class);
38
    }
39
40
    /**
41
     * Get TV shows watchlist
42
     * @return \Generator|Results\TVShow
43
     */
44 1
    public function getTVShows() : \Generator
45
    {
46 1
        return $this->getAccountListItems('watchlist', 'tv', Results\TVShow::class);
47
    }
48
49
    /**
50
     * Add movie in watchlist
51
     * @param  int       $movie_id movie id
52
     * @return WatchList
53
     */
54 2
    public function addMovie(int $movie_id) : WatchList
55
    {
56 2
        return $this->setListItem('watchlist', 'movie', $movie_id, true);
57
    }
58
59
    /**
60
     * Remove movie from watchlist
61
     * @param  int       $movie_id movie id
62
     * @return WatchList
63
     */
64 1
    public function removeMovie(int $movie_id) : WatchList
65
    {
66 1
        return $this->setListItem('watchlist', 'movie', $movie_id, false);
67
    }
68
69
    /**
70
     * Add TV show in watchlist
71
     * @param  int    $tvshow_id TV show id
72
     * @return WatchList
73
     */
74 1
    public function addTVShow(int $tvshow_id) : WatchList
75
    {
76 1
        return $this->setListItem('watchlist', 'tv', $tvshow_id, true);
77
    }
78
79
    /**
80
     * Remove TV show from watchlist
81
     * @param  int    $tvshow_id TV show id
82
     * @return WatchList
83
     */
84 1
    public function removeTVShow(int $tvshow_id) : WatchList
85
    {
86 1
        return $this->setListItem('watchlist', 'tv', $tvshow_id, false);
87
    }
88
}
89