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\Abstracts\Account; |
19
|
|
|
use VfacTmdb\Traits\ListItems; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Class to manipulate account favorite |
23
|
|
|
* @package Tmdb |
24
|
|
|
* @author Vincent Faliès <[email protected]> |
25
|
|
|
* @copyright Copyright (c) 2017 |
26
|
|
|
*/ |
27
|
|
View Code Duplication |
class Favorite extends Account |
|
|
|
|
28
|
|
|
{ |
29
|
|
|
use ListItems; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Get account favorite movies |
33
|
|
|
* @return \Generator|Results\Movie |
34
|
|
|
*/ |
35
|
1 |
|
public function getMovies() : \Generator |
36
|
|
|
{ |
37
|
1 |
|
return $this->getAccountListItems('favorite', 'movies', Results\Movie::class); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Get account favorite tvshows |
42
|
|
|
* @return \Generator|Results\TVShow |
43
|
|
|
*/ |
44
|
1 |
|
public function getTVShows() : \Generator |
45
|
|
|
{ |
46
|
1 |
|
return $this->getAccountListItems('favorite', 'tv', Results\TVShow::class); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Marl a movie as favorite |
51
|
|
|
* @param int $movie_id Movie id |
52
|
|
|
* @return Favorite |
53
|
|
|
*/ |
54
|
2 |
|
public function markMovieAsFavorite(int $movie_id) : Favorite |
55
|
|
|
{ |
56
|
2 |
|
return $this->setListItem('favorite', 'movie', $movie_id, true); |
57
|
|
|
} |
58
|
|
|
/** |
59
|
|
|
|
60
|
|
|
* Unmark a movie as favorite |
61
|
|
|
* @param int $movie_id Movie id |
62
|
|
|
* @return Favorite |
63
|
|
|
*/ |
64
|
1 |
|
public function unmarkMovieAsFavorite(int $movie_id) : Favorite |
65
|
|
|
{ |
66
|
1 |
|
return $this->setListItem('favorite', 'movie', $movie_id, false); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Mark a TV show as favorkite |
71
|
|
|
* @param int $tvshow_id TV show id |
72
|
|
|
* @return Favorite |
73
|
|
|
*/ |
74
|
1 |
|
public function markTVShowAsFavorite(int $tvshow_id) : Favorite |
75
|
|
|
{ |
76
|
1 |
|
return $this->setListItem('favorite', 'tv', $tvshow_id, true); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Unmark a TV show as favorite |
81
|
|
|
* @param int $tvshow_id TV Show id |
82
|
|
|
* @return Favorite |
83
|
|
|
*/ |
84
|
1 |
|
public function unmarkTVShowAsFavorite(int $tvshow_id) : Favorite |
85
|
|
|
{ |
86
|
1 |
|
return $this->setListItem('favorite', '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.