1 | <?php declare(strict_types=1); |
||
26 | class Manga extends API |
||
27 | { |
||
28 | |||
29 | const READING = 'Reading'; |
||
30 | const PLAN_TO_READ = 'Plan to Read'; |
||
31 | const DROPPED = 'Dropped'; |
||
32 | const ON_HOLD = 'On Hold'; |
||
33 | const COMPLETED = 'Completed'; |
||
34 | |||
35 | /** |
||
36 | * Map API constants to display constants |
||
37 | * @var array |
||
38 | */ |
||
39 | protected $const_map = [ |
||
40 | MangaReadingStatus::READING => self::READING, |
||
41 | MangaReadingStatus::PLAN_TO_READ => self::PLAN_TO_READ, |
||
42 | MangaReadingStatus::ON_HOLD => self::ON_HOLD, |
||
43 | MangaReadingStatus::DROPPED => self::DROPPED, |
||
44 | MangaReadingStatus::COMPLETED => self::COMPLETED |
||
45 | ]; |
||
46 | |||
47 | protected $status_map = [ |
||
48 | 'current' => self::READING, |
||
49 | 'planned' => self::PLAN_TO_READ, |
||
50 | 'completed' => self::COMPLETED, |
||
51 | 'on_hold' => self::ON_HOLD, |
||
52 | 'dropped' => self::DROPPED |
||
53 | ]; |
||
54 | |||
55 | /** |
||
56 | * @var Aviat\AnimeClient\API\Kitsu\KitsuModel |
||
57 | */ |
||
58 | protected $kitsuModel; |
||
59 | |||
60 | public function __construct(ContainerInterface $container) |
||
66 | |||
67 | /** |
||
68 | * Get a category out of the full list |
||
69 | * |
||
70 | * @param string $status |
||
71 | * @return array |
||
72 | */ |
||
73 | public function getList($status) |
||
79 | |||
80 | /** |
||
81 | * Get the details of a manga |
||
82 | * |
||
83 | * @param string $manga_id |
||
84 | * @return array |
||
85 | */ |
||
86 | public function getManga($manga_id) |
||
90 | |||
91 | /** |
||
92 | * Create a new manga list item |
||
93 | * |
||
94 | * @param array $data |
||
95 | * @return bool |
||
96 | */ |
||
97 | public function createLibraryItem(array $data): bool |
||
101 | |||
102 | /** |
||
103 | * Get information about a specific list item |
||
104 | * for editing/updating that item |
||
105 | * |
||
106 | * @param string $itemId |
||
107 | * @return array |
||
108 | */ |
||
109 | public function getLibraryItem(string $itemId): array |
||
113 | |||
114 | /** |
||
115 | * Update a list entry |
||
116 | * |
||
117 | * @param array $data |
||
118 | * @return array |
||
119 | */ |
||
120 | public function updateLibraryItem(array $data): array |
||
124 | |||
125 | /** |
||
126 | * Remove a list entry |
||
127 | * |
||
128 | * @param string $itemId |
||
129 | * @return bool |
||
130 | */ |
||
131 | public function deleteLibraryItem(string $itemId): bool |
||
135 | |||
136 | /** |
||
137 | * Search for anime by name |
||
138 | * |
||
139 | * @param string $name |
||
140 | * @return array |
||
141 | */ |
||
142 | public function search($name) |
||
146 | |||
147 | /** |
||
148 | * Map transformed anime data to be organized by reading status |
||
149 | * |
||
150 | * @param array $data |
||
151 | * @return array |
||
152 | */ |
||
153 | private function mapByStatus($data) |
||
174 | } |
||
175 | // End of MangaModel.php |