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 |
|
|
|
|
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
|
|
|
|
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.