1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
/** |
3
|
|
|
* Anime List Client |
4
|
|
|
* |
5
|
|
|
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists |
6
|
|
|
* |
7
|
|
|
* PHP version 7 |
8
|
|
|
* |
9
|
|
|
* @package AnimeListClient |
10
|
|
|
* @author Timothy J. Warren <[email protected]> |
11
|
|
|
* @copyright 2015 - 2017 Timothy J. Warren |
12
|
|
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License |
13
|
|
|
* @version 4.0 |
14
|
|
|
* @link https://github.com/timw4mail/HummingBirdAnimeClient |
15
|
|
|
*/ |
16
|
|
|
|
17
|
|
|
namespace Aviat\AnimeClient\API; |
18
|
|
|
|
19
|
|
|
use Aviat\AnimeClient\API\Kitsu\Enum\{ |
20
|
|
|
AnimeWatchingStatus as KAWS, |
21
|
|
|
MangaReadingStatus as KMRS |
22
|
|
|
}; |
23
|
|
|
use Aviat\AnimeClient\API\MAL\Enum\{AnimeWatchingStatus, MangaReadingStatus}; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Constants and mappings for the My Anime List API |
27
|
|
|
*/ |
28
|
|
|
class MAL { |
29
|
|
|
const AUTH_URL = 'https://myanimelist.net/api/account/verify_credentials.xml'; |
30
|
|
|
const BASE_URL = 'https://myanimelist.net/api/'; |
31
|
|
|
|
32
|
|
|
const KITSU_MAL_WATCHING_STATUS_MAP = [ |
33
|
|
|
KAWS::WATCHING => AnimeWatchingStatus::WATCHING, |
34
|
|
|
KAWS::COMPLETED => AnimeWatchingStatus::COMPLETED, |
35
|
|
|
KAWS::ON_HOLD => AnimeWatchingStatus::ON_HOLD, |
36
|
|
|
KAWS::DROPPED => AnimeWatchingStatus::DROPPED, |
37
|
|
|
KAWS::PLAN_TO_WATCH => AnimeWatchingStatus::PLAN_TO_WATCH |
38
|
|
|
]; |
39
|
|
|
|
40
|
|
View Code Duplication |
public static function getIdToWatchingStatusMap() |
|
|
|
|
41
|
|
|
{ |
42
|
|
|
return [ |
43
|
|
|
1 => AnimeWatchingStatus::WATCHING, |
44
|
|
|
2 => AnimeWatchingStatus::COMPLETED, |
45
|
|
|
3 => AnimeWatchingStatus::ON_HOLD, |
46
|
|
|
4 => AnimeWatchingStatus::DROPPED, |
47
|
|
|
6 => AnimeWatchingStatus::PLAN_TO_WATCH, |
48
|
|
|
'watching' => AnimeWatchingStatus::WATCHING, |
49
|
|
|
'completed' => AnimeWatchingStatus::COMPLETED, |
50
|
|
|
'onhold' => AnimeWatchingStatus::ON_HOLD, |
51
|
|
|
'dropped' => AnimeWatchingStatus::DROPPED, |
52
|
|
|
'plantowatch' => AnimeWatchingStatus::PLAN_TO_WATCH |
53
|
|
|
]; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
View Code Duplication |
public static function getIdToReadingStatusMap() |
|
|
|
|
57
|
|
|
{ |
58
|
|
|
return [ |
59
|
|
|
1 => MangaReadingStatus::READING, |
60
|
|
|
2 => MangaReadingStatus::COMPLETED, |
61
|
|
|
3 => MangaReadingStatus::ON_HOLD, |
62
|
|
|
4 => MangaReadingStatus::DROPPED, |
63
|
|
|
6 => MangaReadingStatus::PLAN_TO_READ, |
64
|
|
|
'reading' => MangaReadingStatus::READING, |
65
|
|
|
'completed' => MangaReadingStatus::COMPLETED, |
66
|
|
|
'onhold' => MangaReadingStatus::ON_HOLD, |
67
|
|
|
'dropped' => MangaReadingStatus::DROPPED, |
68
|
|
|
'plantoread' => MangaReadingStatus::PLAN_TO_WATCH |
69
|
|
|
]; |
70
|
|
|
} |
71
|
|
|
} |
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.