Browse Source

Misc code cleanup

pull/14/head
Timothy Warren 11 months ago
parent
commit
f3c85da8cc
43 changed files with 230 additions and 297 deletions
  1. 0
    2
      app/config/cache.toml.example
  2. 1
    1
      app/views/collection/edit.php
  3. 1
    1
      src/API/APIRequestBuilder.php
  4. 2
    2
      src/API/Anilist.php
  5. 7
    18
      src/API/Anilist/Model.php
  6. 0
    12
      src/API/Anilist/Transformer/AnimeListTransformer.php
  7. 2
    13
      src/API/Anilist/Transformer/MangaListTransformer.php
  8. 6
    6
      src/API/Enum/AnimeWatchingStatus/Anilist.php
  9. 5
    5
      src/API/Enum/AnimeWatchingStatus/Kitsu.php
  10. 7
    7
      src/API/Enum/AnimeWatchingStatus/Route.php
  11. 7
    7
      src/API/Enum/AnimeWatchingStatus/Title.php
  12. 6
    6
      src/API/Enum/MangaReadingStatus/Anilist.php
  13. 5
    5
      src/API/Enum/MangaReadingStatus/Kitsu.php
  14. 6
    6
      src/API/Enum/MangaReadingStatus/Route.php
  15. 6
    6
      src/API/Enum/MangaReadingStatus/Title.php
  16. 2
    8
      src/API/JsonAPI.php
  17. 6
    6
      src/API/Kitsu.php
  18. 3
    3
      src/API/Kitsu/Enum/AnimeAiringStatus.php
  19. 2
    1
      src/API/Kitsu/KitsuRequestBuilder.php
  20. 2
    1
      src/API/Kitsu/KitsuTrait.php
  21. 2
    6
      src/API/Kitsu/ListItem.php
  22. 9
    8
      src/API/Kitsu/Model.php
  23. 6
    6
      src/API/Mapping/AnimeWatchingStatus.php
  24. 6
    6
      src/API/Mapping/MangaReadingStatus.php
  25. 2
    2
      src/AnimeClient.php
  26. 2
    6
      src/Command/BaseCommand.php
  27. 58
    58
      src/Command/ClearThumbnails.php
  28. 5
    5
      src/Controller.php
  29. 5
    5
      src/Controller/AnimeCollection.php
  30. 3
    3
      src/Controller/MangaCollection.php
  31. 4
    5
      src/Controller/Misc.php
  32. 16
    13
      src/Dispatcher.php
  33. 10
    17
      src/FormGenerator.php
  34. 4
    2
      src/MenuGenerator.php
  35. 1
    5
      src/Model/API.php
  36. 2
    2
      src/Model/Anime.php
  37. 5
    0
      src/Model/AnimeCollection.php
  38. 3
    3
      src/Model/Collection.php
  39. 0
    3
      src/Model/DB.php
  40. 4
    5
      src/Model/Settings.php
  41. 0
    14
      src/RoutingBase.php
  42. 4
    4
      src/UrlGenerator.php
  43. 3
    3
      src/Util.php

+ 0
- 2
app/config/cache.toml.example View File

@@ -20,5 +20,3 @@ host = "127.0.0.1"
20 20
 
21 21
 # Database number
22 22
 database = 2
23
-
24
-[options]

+ 1
- 1
app/views/collection/edit.php View File

@@ -2,7 +2,7 @@
2 2
 <main>
3 3
 	<h2>Edit Anime Collection Item</h2>
4 4
 	<form action="<?= $action_url ?>" method="post">
5
-		<table class="invisible form borderless">
5
+		<table class="invisible form">
6 6
 			<tbody>
7 7
 				<tr>
8 8
 					<td rowspan="6" class="align-center">

+ 1
- 1
src/API/APIRequestBuilder.php View File

@@ -315,7 +315,7 @@ class APIRequestBuilder {
315 315
 	 * @param string $type
316 316
 	 * @return void
317 317
 	 */
318
-	private function resetState($url, $type = 'GET')
318
+	private function resetState($url, $type = 'GET'): void
319 319
 	{
320 320
 		$requestUrl = $url ?: $this->baseUrl;
321 321
 

+ 2
- 2
src/API/Anilist.php View File

@@ -65,7 +65,7 @@ final class Anilist {
65 65
 		MangaReadingStatus::PLAN_TO_READ => KMRS::PLAN_TO_READ,
66 66
 	];
67 67
 
68
-	public static function getIdToWatchingStatusMap()
68
+	public static function getIdToWatchingStatusMap(): array
69 69
 	{
70 70
 		return [
71 71
 			'CURRENT' => AnimeWatchingStatus::WATCHING,
@@ -77,7 +77,7 @@ final class Anilist {
77 77
 		];
78 78
 	}
79 79
 
80
-	public static function getIdToReadingStatusMap()
80
+	public static function getIdToReadingStatusMap(): array
81 81
 	{
82 82
 		return [
83 83
 			'CURRENT' => MangaReadingStatus::READING,

+ 7
- 18
src/API/Anilist/Model.php View File

@@ -100,7 +100,7 @@ final class Model
100 100
 		$config = $this->container->get('config');
101 101
 		$anilistUser = $config->get(['anilist', 'username']);
102 102
 
103
-		if ( ! is_string($anilistUser))
103
+		if ( ! \is_string($anilistUser))
104 104
 		{
105 105
 			throw new InvalidArgumentException('Anilist username is not defined in config');
106 106
 		}
@@ -151,10 +151,9 @@ final class Model
151 151
 	 * Create a list item with all the relevant data
152 152
 	 *
153 153
 	 * @param array $data
154
-	 * @param string $type
155 154
 	 * @return Request
156 155
 	 */
157
-	public function createFullListItem(array $data, string $type = 'anime'): Request
156
+	public function createFullListItem(array $data): Request
158 157
 	{
159 158
 		$createData = $data['data'];
160 159
 		$mediaId = $this->getMediaIdFromMalId($data['mal_id']);
@@ -168,6 +167,7 @@ final class Model
168 167
 	 * Get the data for a specific list item, generally for editing
169 168
 	 *
170 169
 	 * @param string $malId - The unique identifier of that list item
170
+	 * @param string $type - Them media type (anime/manga)
171 171
 	 * @return mixed
172 172
 	 */
173 173
 	public function getListItem(string $malId, string $type): array
@@ -185,6 +185,7 @@ final class Model
185 185
 	 * Increase the watch count for the current list item
186 186
 	 *
187 187
 	 * @param FormItem $data
188
+	 * @param string $type - Them media type (anime/manga)
188 189
 	 * @return Request
189 190
 	 */
190 191
 	public function incrementListItem(FormItem $data, string $type): Request
@@ -198,7 +199,7 @@ final class Model
198 199
 	 * Modify a list item
199 200
 	 *
200 201
 	 * @param FormItem $data
201
-	 * @param int [$id]
202
+	 * @param string $type - Them media type (anime/manga)
202 203
 	 * @return Request
203 204
 	 */
204 205
 	public function updateListItem(FormItem $data, string $type): Request
@@ -225,6 +226,7 @@ final class Model
225 226
 	 * Get the id of the specific list entry from the malId
226 227
 	 *
227 228
 	 * @param string $malId
229
+	 * @param string $type - The media type (anime/manga)
228 230
 	 * @return string
229 231
 	 */
230 232
 	public function getListIdFromMalId(string $malId, string $type): ?string
@@ -234,7 +236,7 @@ final class Model
234 236
 	}
235 237
 
236 238
 	/**
237
-	 * Get the Anilist media id from its MAL id
239
+	 * Get the Anilist list item id from the media id from its MAL id
238 240
 	 * this way is more accurate than getting the list item id
239 241
 	 * directly from the MAL id
240 242
 	 */
@@ -248,13 +250,6 @@ final class Model
248 250
 			'userName' => $anilistUser,
249 251
 		]);
250 252
 
251
-		/* dump([
252
-			'media_id' => $mediaId,
253
-			'userName' => $anilistUser,
254
-			'response' => $info,
255
-		]);
256
-		die(); */
257
-
258 253
 		return (string)$info['data']['MediaList']['id'];
259 254
 	}
260 255
 
@@ -272,12 +267,6 @@ final class Model
272 267
 			'type' => mb_strtoupper($type),
273 268
 		]);
274 269
 
275
-		/* dump([
276
-			'mal_id' => $malId,
277
-			'response' => $info,
278
-		]);
279
-		die(); */
280
-
281 270
 		return (string)$info['data']['Media']['id'];
282 271
 	}
283 272
 }

+ 0
- 12
src/API/Anilist/Transformer/AnimeListTransformer.php View File

@@ -56,16 +56,4 @@ class AnimeListTransformer extends AbstractTransformer {
56 56
 			],
57 57
 		]);
58 58
 	}
59
-
60
-	/**
61
-	 * Transform a set of structures
62
-	 *
63
-	 * @param  array|object $collection
64
-	 * @return array
65
-	 */
66
-	public function untransformCollection($collection): array
67
-	{
68
-		$list = (array)$collection;
69
-		return array_map([$this, 'untransform'], $list);
70
-	}
71 59
 }

+ 2
- 13
src/API/Anilist/Transformer/MangaListTransformer.php View File

@@ -18,6 +18,7 @@ namespace Aviat\AnimeClient\API\Anilist\Transformer;
18 18
 
19 19
 use Aviat\AnimeClient\API\Enum\MangaReadingStatus\Anilist as AnilistStatus;
20 20
 use Aviat\AnimeClient\API\Mapping\MangaReadingStatus;
21
+use Aviat\AnimeClient\Types\MangaListItem;
21 22
 use Aviat\AnimeClient\Types\FormItem;
22 23
 
23 24
 use Aviat\Ion\Transformer\AbstractTransformer;
@@ -28,7 +29,7 @@ class MangaListTransformer extends AbstractTransformer {
28 29
 
29 30
 	public function transform($item)
30 31
 	{
31
-
32
+		return new MangaListItem([]);
32 33
 	}
33 34
 
34 35
 	/**
@@ -56,16 +57,4 @@ class MangaListTransformer extends AbstractTransformer {
56 57
 			]
57 58
 		]);
58 59
 	}
59
-
60
-	/**
61
-	 * Transform a set of structures
62
-	 *
63
-	 * @param  array|object $collection
64
-	 * @return array
65
-	 */
66
-	public function untransformCollection($collection): array
67
-	{
68
-		$list = (array)$collection;
69
-		return array_map([$this, 'untransform'], $list);
70
-	}
71 60
 }

+ 6
- 6
src/API/Enum/AnimeWatchingStatus/Anilist.php View File

@@ -22,10 +22,10 @@ use Aviat\Ion\Enum;
22 22
  * Possible values for watching status for the current anime
23 23
  */
24 24
 final class Anilist extends Enum {
25
-	const WATCHING = 'CURRENT';
26
-	const COMPLETED = 'COMPLETED';
27
-	const ON_HOLD = 'PAUSED';
28
-	const DROPPED = 'DROPPED';
29
-	const PLAN_TO_WATCH = 'PLANNING';
30
-	const REPEATING = 'REPEATING';
25
+	public const WATCHING = 'CURRENT';
26
+	public const COMPLETED = 'COMPLETED';
27
+	public const ON_HOLD = 'PAUSED';
28
+	public const DROPPED = 'DROPPED';
29
+	public const PLAN_TO_WATCH = 'PLANNING';
30
+	public const REPEATING = 'REPEATING';
31 31
 }

+ 5
- 5
src/API/Enum/AnimeWatchingStatus/Kitsu.php View File

@@ -22,9 +22,9 @@ use Aviat\Ion\Enum;
22 22
  * Possible values for watching status for the current anime
23 23
  */
24 24
 final class Kitsu extends Enum {
25
-	const WATCHING = 'current';
26
-	const PLAN_TO_WATCH = 'planned';
27
-	const ON_HOLD = 'on_hold';
28
-	const DROPPED = 'dropped';
29
-	const COMPLETED = 'completed';
25
+	public const WATCHING = 'current';
26
+	public const PLAN_TO_WATCH = 'planned';
27
+	public const ON_HOLD = 'on_hold';
28
+	public const DROPPED = 'dropped';
29
+	public const COMPLETED = 'completed';
30 30
 }

+ 7
- 7
src/API/Enum/AnimeWatchingStatus/Route.php View File

@@ -16,16 +16,16 @@
16 16
 
17 17
 namespace Aviat\AnimeClient\API\Enum\AnimeWatchingStatus;
18 18
 
19
-use Aviat\Ion\Enum as Enum;
19
+use Aviat\Ion\Enum;
20 20
 
21 21
 /**
22 22
  * Possible values for current watching status of anime
23 23
  */
24 24
 final class Route extends Enum {
25
-	const ALL = 'all';
26
-	const WATCHING = 'watching';
27
-	const PLAN_TO_WATCH = 'plan_to_watch';
28
-	const DROPPED = 'dropped';
29
-	const ON_HOLD = 'on_hold';
30
-	const COMPLETED = 'completed';
25
+	public const ALL = 'all';
26
+	public const WATCHING = 'watching';
27
+	public const PLAN_TO_WATCH = 'plan_to_watch';
28
+	public const DROPPED = 'dropped';
29
+	public const ON_HOLD = 'on_hold';
30
+	public const COMPLETED = 'completed';
31 31
 }

+ 7
- 7
src/API/Enum/AnimeWatchingStatus/Title.php View File

@@ -16,16 +16,16 @@
16 16
 
17 17
 namespace Aviat\AnimeClient\API\Enum\AnimeWatchingStatus;
18 18
 
19
-use Aviat\Ion\Enum as Enum;
19
+use Aviat\Ion\Enum;
20 20
 
21 21
 /**
22 22
  * Possible values for current watching status of anime
23 23
  */
24 24
 final class Title extends Enum {
25
-	const ALL = 'All';
26
-	const WATCHING = 'Currently Watching';
27
-	const PLAN_TO_WATCH = 'Plan to Watch';
28
-	const DROPPED = 'Dropped';
29
-	const ON_HOLD = 'On Hold';
30
-	const COMPLETED = 'Completed';
25
+	public const ALL = 'All';
26
+	public const WATCHING = 'Currently Watching';
27
+	public const PLAN_TO_WATCH = 'Plan to Watch';
28
+	public const DROPPED = 'Dropped';
29
+	public const ON_HOLD = 'On Hold';
30
+	public const COMPLETED = 'Completed';
31 31
 }

+ 6
- 6
src/API/Enum/MangaReadingStatus/Anilist.php View File

@@ -22,10 +22,10 @@ use Aviat\Ion\Enum;
22 22
  * Possible values for watching status for the current anime
23 23
  */
24 24
 final class Anilist extends Enum {
25
-	const READING = 'CURRENT';
26
-	const COMPLETED = 'COMPLETED';
27
-	const ON_HOLD = 'PAUSED';
28
-	const DROPPED = 'DROPPED';
29
-	const PLAN_TO_READ = 'PLANNING';
30
-	const REPEATING = 'REPEATING';
25
+	public const READING = 'CURRENT';
26
+	public const COMPLETED = 'COMPLETED';
27
+	public const ON_HOLD = 'PAUSED';
28
+	public const DROPPED = 'DROPPED';
29
+	public const PLAN_TO_READ = 'PLANNING';
30
+	public const REPEATING = 'REPEATING';
31 31
 }

+ 5
- 5
src/API/Enum/MangaReadingStatus/Kitsu.php View File

@@ -22,9 +22,9 @@ use Aviat\Ion\Enum;
22 22
  * Possible values for current reading status of manga
23 23
  */
24 24
 final class Kitsu extends Enum {
25
-	const READING = 'current';
26
-	const PLAN_TO_READ = 'planned';
27
-	const DROPPED = 'dropped';
28
-	const ON_HOLD = 'on_hold';
29
-	const COMPLETED = 'completed';
25
+	public const READING = 'current';
26
+	public const PLAN_TO_READ = 'planned';
27
+	public const DROPPED = 'dropped';
28
+	public const ON_HOLD = 'on_hold';
29
+	public const COMPLETED = 'completed';
30 30
 }

+ 6
- 6
src/API/Enum/MangaReadingStatus/Route.php View File

@@ -22,10 +22,10 @@ use Aviat\Ion\Enum;
22 22
  * Possible values for current reading status of manga
23 23
  */
24 24
 final class Route extends Enum {
25
-	const ALL = 'all';
26
-	const READING = 'reading';
27
-	const PLAN_TO_READ = 'plan_to_read';
28
-	const DROPPED = 'dropped';
29
-	const ON_HOLD = 'on_hold';
30
-	const COMPLETED = 'completed';
25
+	public const ALL = 'all';
26
+	public const READING = 'reading';
27
+	public const PLAN_TO_READ = 'plan_to_read';
28
+	public const DROPPED = 'dropped';
29
+	public const ON_HOLD = 'on_hold';
30
+	public const COMPLETED = 'completed';
31 31
 }

+ 6
- 6
src/API/Enum/MangaReadingStatus/Title.php View File

@@ -22,10 +22,10 @@ use Aviat\Ion\Enum;
22 22
  * Possible values for current reading status of manga
23 23
  */
24 24
 final class Title extends Enum {
25
-	const ALL = 'All';
26
-	const READING = 'Currently Reading';
27
-	const PLAN_TO_READ = 'Plan to Read';
28
-	const DROPPED = 'Dropped';
29
-	const ON_HOLD = 'On Hold';
30
-	const COMPLETED = 'Completed';
25
+	public const ALL = 'All';
26
+	public const READING = 'Currently Reading';
27
+	public const PLAN_TO_READ = 'Plan to Read';
28
+	public const DROPPED = 'Dropped';
29
+	public const ON_HOLD = 'On Hold';
30
+	public const COMPLETED = 'Completed';
31 31
 }

+ 2
- 8
src/API/JsonAPI.php View File

@@ -21,9 +21,7 @@ namespace Aviat\AnimeClient\API;
21 21
  */
22 22
 final class JsonAPI {
23 23
 
24
-	/**
25
-	 * The full data array
26
-	 *
24
+	/*
27 25
 	 * Basic structure is generally like so:
28 26
 	 * [
29 27
 	 * 	'id' => '12016665',
@@ -35,10 +33,7 @@ final class JsonAPI {
35 33
 	 *
36 34
 	 * 	]
37 35
 	 * ]
38
-	 *
39
-	 * @var array
40 36
 	 */
41
-	protected $data = [];
42 37
 
43 38
 	/**
44 39
 	 * Inline all included data
@@ -214,8 +209,7 @@ final class JsonAPI {
214 209
 							$dataType = $props['data']['type'];
215 210
 
216 211
 							$relationship =& $organized[$type][$id]['relationships'][$relType];
217
-							unset($relationship['links']);
218
-							unset($relationship['data']);
212
+							unset($relationship['links'], $relationship['data']);
219 213
 
220 214
 							if ($relType === $dataType)
221 215
 							{

+ 6
- 6
src/API/Kitsu.php View File

@@ -23,11 +23,11 @@ use DateTimeImmutable;
23 23
  * Data massaging helpers for the Kitsu API
24 24
  */
25 25
 final class Kitsu {
26
-	const AUTH_URL = 'https://kitsu.io/api/oauth/token';
27
-	const AUTH_USER_ID_KEY = 'kitsu-auth-userid';
28
-	const AUTH_TOKEN_CACHE_KEY = 'kitsu-auth-token';
29
-	const AUTH_TOKEN_EXP_CACHE_KEY = 'kitsu-auth-token-expires';
30
-	const AUTH_TOKEN_REFRESH_CACHE_KEY = 'kitsu-auth-token-refresh';
26
+	public const AUTH_URL = 'https://kitsu.io/api/oauth/token';
27
+	public const AUTH_USER_ID_KEY = 'kitsu-auth-userid';
28
+	public const AUTH_TOKEN_CACHE_KEY = 'kitsu-auth-token';
29
+	public const AUTH_TOKEN_EXP_CACHE_KEY = 'kitsu-auth-token-expires';
30
+	public const AUTH_TOKEN_REFRESH_CACHE_KEY = 'kitsu-auth-token-refresh';
31 31
 
32 32
 	/**
33 33
 	 * Determine whether an anime is airing, finished airing, or has not yet aired
@@ -163,7 +163,7 @@ final class Kitsu {
163 163
 				'dubs' => $streamingLink['dubs']
164 164
 			];
165 165
 		}
166
-		
166
+
167 167
 		usort($links, function ($a, $b) {
168 168
 			return $a['meta']['name'] <=> $b['meta']['name'];
169 169
 		});

+ 3
- 3
src/API/Kitsu/Enum/AnimeAiringStatus.php View File

@@ -22,8 +22,8 @@ use Aviat\Ion\Enum as BaseEnum;
22 22
  * Status of when anime is being/was/will be aired
23 23
  */
24 24
 final class AnimeAiringStatus extends BaseEnum {
25
-	const NOT_YET_AIRED = 'Not Yet Aired';
26
-	const AIRING = 'Currently Airing';
27
-	const FINISHED_AIRING = 'Finished Airing';
25
+	public const NOT_YET_AIRED = 'Not Yet Aired';
26
+	public const AIRING = 'Currently Airing';
27
+	public const FINISHED_AIRING = 'Finished Airing';
28 28
 }
29 29
 // End of AnimeAiringStatus.php

+ 2
- 1
src/API/Kitsu/KitsuRequestBuilder.php View File

@@ -16,6 +16,7 @@
16 16
 
17 17
 namespace Aviat\AnimeClient\API\Kitsu;
18 18
 
19
+use const Aviat\AnimeClient\USER_AGENT;
19 20
 use Aviat\AnimeClient\API\APIRequestBuilder;
20 21
 
21 22
 final class KitsuRequestBuilder extends APIRequestBuilder {
@@ -32,7 +33,7 @@ final class KitsuRequestBuilder extends APIRequestBuilder {
32 33
 	 * @var array
33 34
 	 */
34 35
 	protected $defaultHeaders = [
35
-		'User-Agent' => "Tim's Anime Client/4.0",
36
+		'User-Agent' =>  USER_AGENT,
36 37
 		'Accept' => 'application/vnd.api+json',
37 38
 		'Content-Type' => 'application/vnd.api+json',
38 39
 		'CLIENT_ID' => 'dd031b32d2f56c990b1425efe6c42ad847e7fe3ab46bf1299f05ecd856bdb7dd',

+ 2
- 1
src/API/Kitsu/KitsuTrait.php View File

@@ -16,6 +16,7 @@
16 16
 
17 17
 namespace Aviat\AnimeClient\API\Kitsu;
18 18
 
19
+use Amp\Artax\Response;
19 20
 use const Aviat\AnimeClient\SESSION_SEGMENT;
20 21
 
21 22
 use function Amp\Promise\wait;
@@ -121,7 +122,7 @@ trait KitsuTrait {
121 122
 	 * @param array $options
122 123
 	 * @return Response
123 124
 	 */
124
-	private function getResponse(string $type, string $url, array $options = [])
125
+	private function getResponse(string $type, string $url, array $options = []): Response
125 126
 	{
126 127
 		$logger = NULL;
127 128
 		if ($this->getContainer())

+ 2
- 6
src/API/Kitsu/ListItem.php View File

@@ -37,7 +37,7 @@ final class ListItem implements ListItemInterface {
37 37
 	use KitsuTrait;
38 38
 
39 39
 	public function create(array $data): Request
40
-	{	
40
+	{
41 41
 		$body = [
42 42
 			'data' => [
43 43
 				'type' => 'libraryEntries',
@@ -61,7 +61,7 @@ final class ListItem implements ListItemInterface {
61 61
 				]
62 62
 			]
63 63
 		];
64
-		
64
+
65 65
 		if (array_key_exists('notes', $data))
66 66
 		{
67 67
 			$body['data']['attributes']['notes'] = $data['notes'];
@@ -78,8 +78,6 @@ final class ListItem implements ListItemInterface {
78 78
 
79 79
 		return $request->setJsonBody($body)
80 80
 			->getFullRequest();
81
-
82
-		// return ($response->getStatus() === 201);
83 81
 	}
84 82
 
85 83
 	public function delete(string $id): Request
@@ -93,8 +91,6 @@ final class ListItem implements ListItemInterface {
93 91
 		}
94 92
 
95 93
 		return $request->getFullRequest();
96
-
97
-		// return ($response->getStatus() === 204);
98 94
 	}
99 95
 
100 96
 	public function get(string $id): array

+ 9
- 8
src/API/Kitsu/Model.php View File

@@ -91,9 +91,10 @@ final class Model {
91 91
 	{
92 92
 		$this->animeTransformer = new AnimeTransformer();
93 93
 		$this->animeListTransformer = new AnimeListTransformer();
94
-		$this->listItem = $listItem;
95 94
 		$this->mangaTransformer = new MangaTransformer();
96 95
 		$this->mangaListTransformer = new MangaListTransformer();
96
+
97
+		$this->listItem = $listItem;
97 98
 	}
98 99
 
99 100
 	/**
@@ -265,7 +266,7 @@ final class Model {
265 266
 	public function getUserData(string $username): array
266 267
 	{
267 268
 		// $userId = $this->getUserIdByUsername($username);
268
-		$data = $this->getRequest("users", [
269
+		$data = $this->getRequest('users', [
269 270
 			'query' => [
270 271
 				'filter' => [
271 272
 					'name' => $username,
@@ -334,7 +335,7 @@ final class Model {
334 335
 	 * @param string $type "anime" or "manga"
335 336
 	 * @return string|NULL
336 337
 	 */
337
-	public function getKitsuIdFromMALId(string $malId, string $type="anime")
338
+	public function getKitsuIdFromMALId(string $malId, string $type='anime'): ?string
338 339
 	{
339 340
 		$options = [
340 341
 			'query' => [
@@ -369,7 +370,7 @@ final class Model {
369 370
 	 * @param string $slug
370 371
 	 * @return Anime
371 372
 	 */
372
-	public function getAnime(string $slug)
373
+	public function getAnime(string $slug): Anime
373 374
 	{
374 375
 		$baseData = $this->getRawMediaData('anime', $slug);
375 376
 
@@ -523,7 +524,7 @@ final class Model {
523 524
 	 * @param string $kitsuAnimeId The id of the anime on Kitsu
524 525
 	 * @return string|null Returns the mal id if it exists, otherwise null
525 526
 	 */
526
-	public function getMalIdForAnime(string $kitsuAnimeId)
527
+	public function getMalIdForAnime(string $kitsuAnimeId): ?string
527 528
 	{
528 529
 		$options = [
529 530
 			'query' => [
@@ -625,7 +626,7 @@ final class Model {
625 626
 	 * Get information about a particular manga
626 627
 	 *
627 628
 	 * @param string $mangaId
628
-	 * @return array
629
+	 * @return MangaPage
629 630
 	 */
630 631
 	public function getMangaById(string $mangaId): MangaPage
631 632
 	{
@@ -808,7 +809,7 @@ final class Model {
808 809
 	 * @param string $kitsuMangaId The id of the manga on Kitsu
809 810
 	 * @return string|null Returns the mal id if it exists, otherwise null
810 811
 	 */
811
-	public function getMalIdForManga(string $kitsuMangaId)
812
+	public function getMalIdForManga(string $kitsuMangaId): ?string
812 813
 	{
813 814
 		$options = [
814 815
 			'query' => [
@@ -920,7 +921,7 @@ final class Model {
920 921
 	}
921 922
 
922 923
 	/**
923
-	 * Get the raw data for the anime id
924
+	 * Get the raw data for the anime/manga id
924 925
 	 *
925 926
 	 * @param string $type
926 927
 	 * @param string $id

+ 6
- 6
src/API/Mapping/AnimeWatchingStatus.php View File

@@ -24,7 +24,7 @@ use Aviat\Ion\Enum;
24 24
  * and url route segments
25 25
  */
26 26
 final class AnimeWatchingStatus extends Enum {
27
-	const ANILIST_TO_KITSU = [
27
+	public const ANILIST_TO_KITSU = [
28 28
 		Anilist::WATCHING => Kitsu::WATCHING,
29 29
 		Anilist::PLAN_TO_WATCH => Kitsu::PLAN_TO_WATCH,
30 30
 		Anilist::COMPLETED => Kitsu::COMPLETED,
@@ -32,7 +32,7 @@ final class AnimeWatchingStatus extends Enum {
32 32
 		Anilist::DROPPED => Kitsu::DROPPED
33 33
 	];
34 34
 
35
-	const KITSU_TO_ANILIST = [
35
+	public const KITSU_TO_ANILIST = [
36 36
 		Kitsu::WATCHING => Anilist::WATCHING,
37 37
 		Kitsu::PLAN_TO_WATCH => Anilist::PLAN_TO_WATCH,
38 38
 		Kitsu::COMPLETED => Anilist::COMPLETED,
@@ -40,7 +40,7 @@ final class AnimeWatchingStatus extends Enum {
40 40
 		Kitsu::DROPPED => Anilist::DROPPED
41 41
 	];
42 42
 
43
-	const KITSU_TO_TITLE = [
43
+	public const KITSU_TO_TITLE = [
44 44
 		Kitsu::WATCHING => Title::WATCHING,
45 45
 		Kitsu::PLAN_TO_WATCH => Title::PLAN_TO_WATCH,
46 46
 		Kitsu::ON_HOLD => Title::ON_HOLD,
@@ -48,7 +48,7 @@ final class AnimeWatchingStatus extends Enum {
48 48
 		Kitsu::COMPLETED => Title::COMPLETED
49 49
 	];
50 50
 
51
-	const ROUTE_TO_KITSU = [
51
+	public const ROUTE_TO_KITSU = [
52 52
 		Route::WATCHING => Kitsu::WATCHING,
53 53
 		Route::PLAN_TO_WATCH => Kitsu::PLAN_TO_WATCH,
54 54
 		Route::ON_HOLD => Kitsu::ON_HOLD,
@@ -56,7 +56,7 @@ final class AnimeWatchingStatus extends Enum {
56 56
 		Route::COMPLETED => Kitsu::COMPLETED
57 57
 	];
58 58
 
59
-	const ROUTE_TO_TITLE = [
59
+	public const ROUTE_TO_TITLE = [
60 60
 		Route::ALL => Title::ALL,
61 61
 		Route::WATCHING => Title::WATCHING,
62 62
 		Route::PLAN_TO_WATCH => Title::PLAN_TO_WATCH,
@@ -65,7 +65,7 @@ final class AnimeWatchingStatus extends Enum {
65 65
 		Route::COMPLETED => Title::COMPLETED
66 66
 	];
67 67
 
68
-	const TITLE_TO_ROUTE = [
68
+	public const TITLE_TO_ROUTE = [
69 69
 		Title::ALL => Route::ALL,
70 70
 		Title::WATCHING => Route::WATCHING,
71 71
 		Title::PLAN_TO_WATCH => Route::PLAN_TO_WATCH,

+ 6
- 6
src/API/Mapping/MangaReadingStatus.php View File

@@ -24,7 +24,7 @@ use Aviat\Ion\Enum;
24 24
  * and url route segments
25 25
  */
26 26
 final class MangaReadingStatus extends Enum {
27
-	const ANILIST_TO_KITSU = [
27
+	public const ANILIST_TO_KITSU = [
28 28
 		Anilist::READING => Kitsu::READING,
29 29
 		Anilist::PLAN_TO_READ => Kitsu::PLAN_TO_READ,
30 30
 		Anilist::COMPLETED => Kitsu::COMPLETED,
@@ -32,7 +32,7 @@ final class MangaReadingStatus extends Enum {
32 32
 		Anilist::DROPPED => Kitsu::DROPPED
33 33
 	];
34 34
 
35
-	const KITSU_TO_ANILIST = [
35
+	public const KITSU_TO_ANILIST = [
36 36
 		Kitsu::READING => Anilist::READING,
37 37
 		Kitsu::PLAN_TO_READ => Anilist::PLAN_TO_READ,
38 38
 		Kitsu::COMPLETED => Anilist::COMPLETED,
@@ -40,7 +40,7 @@ final class MangaReadingStatus extends Enum {
40 40
 		Kitsu::DROPPED => Anilist::DROPPED
41 41
 	];
42 42
 
43
-	const KITSU_TO_TITLE = [
43
+	public const KITSU_TO_TITLE = [
44 44
 		Kitsu::READING => Title::READING,
45 45
 		Kitsu::PLAN_TO_READ => Title::PLAN_TO_READ,
46 46
 		Kitsu::COMPLETED => Title::COMPLETED,
@@ -48,7 +48,7 @@ final class MangaReadingStatus extends Enum {
48 48
 		Kitsu::DROPPED => Title::DROPPED,
49 49
 	];
50 50
 
51
-	const ROUTE_TO_KITSU = 	[
51
+	public const ROUTE_TO_KITSU = 	[
52 52
 		Route::PLAN_TO_READ => Kitsu::PLAN_TO_READ,
53 53
 		Route::READING => Kitsu::READING,
54 54
 		Route::COMPLETED => Kitsu::COMPLETED,
@@ -56,7 +56,7 @@ final class MangaReadingStatus extends Enum {
56 56
 		Route::ON_HOLD => Kitsu::ON_HOLD,
57 57
 	];
58 58
 
59
-	const ROUTE_TO_TITLE = [
59
+	public const ROUTE_TO_TITLE = [
60 60
 		Route::ALL => Title::ALL,
61 61
 		Route::PLAN_TO_READ => Title::PLAN_TO_READ,
62 62
 		Route::READING => Title::READING,
@@ -65,7 +65,7 @@ final class MangaReadingStatus extends Enum {
65 65
 		Route::ON_HOLD => Title::ON_HOLD,
66 66
 	];
67 67
 
68
-	const TITLE_TO_KITSU = [
68
+	public const TITLE_TO_KITSU = [
69 69
 		Title::PLAN_TO_READ => Kitsu::PLAN_TO_READ,
70 70
 		Title::READING => Kitsu::READING,
71 71
 		Title::COMPLETED => Kitsu::COMPLETED,

+ 2
- 2
src/AnimeClient.php View File

@@ -246,7 +246,7 @@ function getLocalImg ($kitsuUrl, $webp = TRUE): string
246 246
  * @param int $height
247 247
  * @param string $text
248 248
  */
249
-function createPlaceholderImage ($path, $width, $height, $text = 'Image Unavailable')
249
+function createPlaceholderImage ($path, $width, $height, $text = 'Image Unavailable'): void
250 250
 {
251 251
 	$width = $width ?? 200;
252 252
 	$height = $height ?? 200;
@@ -268,7 +268,7 @@ function createPlaceholderImage ($path, $width, $height, $text = 'Image Unavaila
268 268
 	$fontSize = 10;
269 269
 	$fontWidth = imagefontwidth($fontSize);
270 270
 	$fontHeight = imagefontheight($fontSize);
271
-	$length = strlen($text);
271
+	$length = \strlen($text);
272 272
 	$textWidth = $length * $fontWidth;
273 273
 	$fxPos = (int) ceil((imagesx($img) - $textWidth) / 2);
274 274
 	$fyPos = (int) ceil((imagesy($img) - $fontHeight) / 2);

+ 2
- 6
src/Command/BaseCommand.php View File

@@ -21,13 +21,9 @@ use function Aviat\AnimeClient\loadTomlFile;
21 21
 
22 22
 use Aura\Router\RouterContainer;
23 23
 use Aura\Session\SessionFactory;
24
-use Aviat\AnimeClient\UrlGenerator;
25
-use Aviat\AnimeClient\Util;
26
-use Aviat\AnimeClient\API\CacheTrait;
27
-use Aviat\AnimeClient\API\Anilist;
28
-use Aviat\AnimeClient\API\Kitsu;
24
+use Aviat\AnimeClient\{Model, UrlGenerator, Util};
25
+use Aviat\AnimeClient\API\{Anilist, CacheTrait, Kitsu};
29 26
 use Aviat\AnimeClient\API\Kitsu\KitsuRequestBuilder;
30
-use Aviat\AnimeClient\Model;
31 27
 use Aviat\Banker\Pool;
32 28
 use Aviat\Ion\Config;
33 29
 use Aviat\Ion\Di\{Container, ContainerAware};

+ 58
- 58
src/Command/ClearThumbnails.php View File

@@ -1,59 +1,59 @@
1
-<?php declare(strict_types=1);
2
-/**
3
- * Hummingbird Anime List Client
4
- *
5
- * An API client for Kitsu to manage anime and manga watch lists
6
- *
7
- * PHP version 7.1
8
- *
9
- * @package     HummingbirdAnimeClient
10
- * @author      Timothy J. Warren <tim@timshomepage.net>
11
- * @copyright   2015 - 2018  Timothy J. Warren
12
- * @license     http://www.opensource.org/licenses/mit-license.html  MIT License
13
- * @version     4.1
14
- * @link        https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
15
- */
16
-
17
-namespace Aviat\AnimeClient\Command;
18
-
19
-/**
20
- * Clears out image cache directories
21
- */
22
-class ClearThumbnails extends BaseCommand {
23
-
24
-	public function execute(array $args, array $options = []): void
25
-	{
26
-		$this->clearThumbs();
27
-		$this->echoBox('All cached images have been removed');
28
-	}
29
-
30
-	public function clearThumbs()
31
-	{
32
-		$imgDir = realpath(__DIR__ . '/../../public/images');
33
-
34
-		$paths = [
35
-			'avatars/*.gif',
36
-			'avatars/*.jpg',
37
-			'avatars/*.png',
38
-			'avatars/*.webp',
39
-			'anime/*.jpg',
40
-			'anime/*.png',
41
-			'anime/*.webp',
42
-			'manga/*.jpg',
43
-			'manga/*.png',
44
-			'manga/*.webp',
45
-			'characters/*.jpg',
46
-			'characters/*.png',
47
-			'characters/*.webp',
48
-			'people/*.jpg',
49
-			'people/*.png',
50
-			'people/*.webp',
51
-		];
52
-
53
-		foreach($paths as $path)
54
-		{
55
-			$cmd = "rm -rf {$imgDir}/{$path}";
56
-			exec($cmd);
57
-		}
58
-	}
1
+<?php declare(strict_types=1);
2
+/**
3
+ * Hummingbird Anime List Client
4
+ *
5
+ * An API client for Kitsu to manage anime and manga watch lists
6
+ *
7
+ * PHP version 7.1
8
+ *
9
+ * @package     HummingbirdAnimeClient
10
+ * @author      Timothy J. Warren <tim@timshomepage.net>
11
+ * @copyright   2015 - 2018  Timothy J. Warren
12
+ * @license     http://www.opensource.org/licenses/mit-license.html  MIT License
13
+ * @version     4.1
14
+ * @link        https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
15
+ */
16
+
17
+namespace Aviat\AnimeClient\Command;
18
+
19
+/**
20
+ * Clears out image cache directories
21
+ */
22
+class ClearThumbnails extends BaseCommand {
23
+
24
+	public function execute(array $args, array $options = []): void
25
+	{
26
+		$this->clearThumbs();
27
+		$this->echoBox('All cached images have been removed');
28
+	}
29
+
30
+	private function clearThumbs(): void
31
+	{
32
+		$imgDir = realpath(__DIR__ . '/../../public/images');
33
+
34
+		$paths = [
35
+			'avatars/*.gif',
36
+			'avatars/*.jpg',
37
+			'avatars/*.png',
38
+			'avatars/*.webp',
39
+			'anime/*.jpg',
40
+			'anime/*.png',
41
+			'anime/*.webp',
42
+			'manga/*.jpg',
43
+			'manga/*.png',
44
+			'manga/*.webp',
45
+			'characters/*.jpg',
46
+			'characters/*.png',
47
+			'characters/*.webp',
48
+			'people/*.jpg',
49
+			'people/*.png',
50
+			'people/*.webp',
51
+		];
52
+
53
+		foreach($paths as $path)
54
+		{
55
+			$cmd = "rm -rf {$imgDir}/{$path}";
56
+			exec($cmd);
57
+		}
58
+	}
59 59
 }

+ 5
- 5
src/Controller.php View File

@@ -183,7 +183,7 @@ class Controller {
183 183
 	 * @throws \Aviat\Ion\Di\Exception\NotFoundException
184 184
 	 * @return void
185 185
 	 */
186
-	public function sessionRedirect()
186
+	public function sessionRedirect(): void
187 187
 	{
188 188
 		$target = $this->session->get('redirect_url');
189 189
 		if (empty($target))
@@ -208,7 +208,7 @@ class Controller {
208 208
 	 * @throws \Aviat\Ion\Di\Exception\NotFoundException
209 209
 	 * @return string
210 210
 	 */
211
-	protected function loadPartial($view, string $template, array $data = [])
211
+	protected function loadPartial($view, string $template, array $data = []): string
212 212
 	{
213 213
 		$router = $this->container->get('dispatcher');
214 214
 
@@ -242,7 +242,7 @@ class Controller {
242 242
 	 * @throws \Aviat\Ion\Di\Exception\NotFoundException
243 243
 	 * @return void
244 244
 	 */
245
-	protected function renderFullPage($view, string $template, array $data)
245
+	protected function renderFullPage($view, string $template, array $data): void
246 246
 	{
247 247
 		$csp = [
248 248
 			"default-src 'self'",
@@ -275,7 +275,7 @@ class Controller {
275 275
 	public function notFound(
276 276
 		string $title = 'Sorry, page not found',
277 277
 		string $message = 'Page Not Found'
278
-		)
278
+		): void
279 279
 	{
280 280
 		$this->outputHTML('404', [
281 281
 			'title' => $title,
@@ -383,7 +383,7 @@ class Controller {
383 383
 	 * @throws \Aviat\Ion\Di\Exception\NotFoundException
384 384
 	 * @return void
385 385
 	 */
386
-	protected function outputHTML(string $template, array $data = [], $view = NULL, int $code = 200)
386
+	protected function outputHTML(string $template, array $data = [], $view = NULL, int $code = 200): void
387 387
 	{
388 388
 		if (null === $view)
389 389
 		{

+ 5
- 5
src/Controller/AnimeCollection.php View File

@@ -68,7 +68,7 @@ final class AnimeCollection extends BaseController {
68 68
 	 * @throws \Aviat\Ion\Exception\DoubleRenderException
69 69
 	 * @return void
70 70
 	 */
71
-	public function search()
71
+	public function search(): void
72 72
 	{
73 73
 		$queryParams = $this->request->getQueryParams();
74 74
 		$query = $queryParams['query'];
@@ -84,7 +84,7 @@ final class AnimeCollection extends BaseController {
84 84
 	 * @throws \InvalidArgumentException
85 85
 	 * @return void
86 86
 	 */
87
-	public function index($view)
87
+	public function index($view): void
88 88
 	{
89 89
 		$viewMap = [
90 90
 			'' => 'cover',
@@ -110,7 +110,7 @@ final class AnimeCollection extends BaseController {
110 110
 	 * @throws \InvalidArgumentException
111 111
 	 * @return void
112 112
 	 */
113
-	public function form($id = NULL)
113
+	public function form($id = NULL): void
114 114
 	{
115 115
 		$this->setSessionRedirect();
116 116
 
@@ -161,7 +161,7 @@ final class AnimeCollection extends BaseController {
161 161
 	 * @throws \InvalidArgumentException
162 162
 	 * @return void
163 163
 	 */
164
-	public function add()
164
+	public function add(): void
165 165
 	{
166 166
 		$data = $this->request->getParsedBody();
167 167
 		if (array_key_exists('id', $data))
@@ -182,7 +182,7 @@ final class AnimeCollection extends BaseController {
182 182
 	 *
183 183
 	 * @return void
184 184
 	 */
185
-	public function delete()
185
+	public function delete(): void
186 186
 	{
187 187
 		$data = $this->request->getParsedBody();
188 188
 		if ( ! array_key_exists('hummingbird_id', $data))

+ 3
- 3
src/Controller/MangaCollection.php View File

@@ -138,7 +138,7 @@ final class MangaCollection extends BaseController {
138 138
 	 * @throws \InvalidArgumentException
139 139
 	 * @return void
140 140
 	 */
141
-	public function edit()
141
+	public function edit(): void
142 142
 	{
143 143
 		$data = $this->request->getParsedBody();
144 144
 		if (array_key_exists('hummingbird_id', $data))
@@ -162,7 +162,7 @@ final class MangaCollection extends BaseController {
162 162
 	 * @throws \InvalidArgumentException
163 163
 	 * @return void
164 164
 	 */
165
-	public function add()
165
+	public function add(): void
166 166
 	{
167 167
 		$data = $this->request->getParsedBody();
168 168
 		if (array_key_exists('id', $data))
@@ -183,7 +183,7 @@ final class MangaCollection extends BaseController {
183 183
 	 *
184 184
 	 * @return void
185 185
 	 */
186
-	public function delete()
186
+	public function delete(): void
187 187
 	{
188 188
 		$data = $this->request->getParsedBody();
189 189
 		if ( ! array_key_exists('hummingbird_id', $data))

+ 4
- 5
src/Controller/Misc.php View File

@@ -17,7 +17,6 @@
17 17
 namespace Aviat\AnimeClient\Controller;
18 18
 
19 19
 use Aviat\AnimeClient\Controller as BaseController;
20
-use Aviat\Ion\Di\ContainerInterface;
21 20
 use Aviat\Ion\View\HtmlView;
22 21
 
23 22
 /**
@@ -29,7 +28,7 @@ final class Misc extends BaseController {
29 28
 	 *
30 29
 	 * @return void
31 30
 	 */
32
-	public function clearCache()
31
+	public function clearCache(): void
33 32
 	{
34 33
 		$this->cache->clear();
35 34
 		$this->outputHTML('blank', [
@@ -43,7 +42,7 @@ final class Misc extends BaseController {
43 42
 	 * @param string $status
44 43
 	 * @return void
45 44
 	 */
46
-	public function login(string $status = '')
45
+	public function login(string $status = ''): void
47 46
 	{
48 47
 		$message = '';
49 48
 
@@ -68,7 +67,7 @@ final class Misc extends BaseController {
68 67
 	 *
69 68
 	 * @return void
70 69
 	 */
71
-	public function loginAction()
70
+	public function loginAction(): void
72 71
 	{
73 72
 		$auth = $this->container->get('auth');
74 73
 		$post = $this->request->getParsedBody();
@@ -88,7 +87,7 @@ final class Misc extends BaseController {
88 87
 	 *
89 88
 	 * @return void
90 89
 	 */
91
-	public function logout()
90
+	public function logout(): void
92 91
 	{
93 92
 		$auth = $this->container->get('auth');
94 93
 		$auth->logout();

+ 16
- 13
src/Dispatcher.php View File

@@ -64,8 +64,9 @@ final class Dispatcher extends RoutingBase {
64 64
 	public function __construct(ContainerInterface $container)
65 65
 	{
66 66
 		parent::__construct($container);
67
-		$this->router = $container->get('aura-router')->getMap();
68
-		$this->matcher = $container->get('aura-router')->getMatcher();
67
+		$router = $this->container->get('aura-router');
68
+		$this->router = $router->getMap();
69
+		$this->matcher = $router->getMatcher();
69 70
 		$this->request = $container->get('request');
70 71
 
71 72
 		$this->outputRoutes = $this->setupRoutes();
@@ -99,7 +100,7 @@ final class Dispatcher extends RoutingBase {
99 100
 	 *
100 101
 	 * @return array
101 102
 	 */
102
-	public function getOutputRoutes()
103
+	public function getOutputRoutes(): array
103 104
 	{
104 105
 		return $this->outputRoutes;
105 106
 	}
@@ -171,7 +172,7 @@ final class Dispatcher extends RoutingBase {
171 172
 			$controllerName = $map[$controllerName];
172 173
 		}
173 174
 
174
-		$actionMethod = (array_key_exists('action', $route->attributes))
175
+		$actionMethod = array_key_exists('action', $route->attributes)
175 176
 			? $route->attributes['action']
176 177
 			: NOT_FOUND_METHOD;
177 178
 
@@ -205,9 +206,9 @@ final class Dispatcher extends RoutingBase {
205 206
 	 *
206 207
 	 * @return string
207 208
 	 */
208
-	public function getController()
209
+	public function getController(): string
209 210
 	{
210
-		$routeType = $this->__get('default_list');
211
+		$routeType = $this->config->get('default_list');
211 212
 		$requestUri = $this->request->getUri()->getPath();
212 213
 		$path = trim($requestUri, '/');
213 214
 
@@ -225,7 +226,7 @@ final class Dispatcher extends RoutingBase {
225 226
 			$controller = $routeType;
226 227
 		}
227 228
 
228
-		return $controller;
229
+		return $controller ?? '';
229 230
 	}
230 231
 
231 232
 	/**
@@ -233,11 +234,13 @@ final class Dispatcher extends RoutingBase {
233 234
 	 *
234 235
 	 * @return array
235 236
 	 */
236
-	public function getControllerList()
237
+	public function getControllerList(): array
237 238
 	{
238 239
 		$defaultNamespace = DEFAULT_CONTROLLER_NAMESPACE;
239
-		$path = str_replace('\\', '/', $defaultNamespace);
240
-		$path = str_replace('Aviat/AnimeClient/', '', $path);
240
+		$find = ['\\', 'Aviat/AnimeClient/'];
241
+		$replace = ['/', ''];
242
+
243
+		$path = str_replace($find, $replace, $defaultNamespace);
241 244
 		$path = trim($path, '/');
242 245
 		$actualPath = realpath(_dir(SRC_DIR, $path));
243 246
 		$classFiles = glob("{$actualPath}/*.php");
@@ -265,7 +268,7 @@ final class Dispatcher extends RoutingBase {
265 268
 	 * @param  array  $params
266 269
 	 * @return void
267 270
 	 */
268
-	protected function call($controllerName, $method, array $params)
271
+	protected function call($controllerName, $method, array $params): void
269 272
 	{
270 273
 		$logger = $this->container->getLogger('default');
271 274
 
@@ -347,7 +350,7 @@ final class Dispatcher extends RoutingBase {
347 350
 	 *
348 351
 	 * @return array
349 352
 	 */
350
-	protected function setupRoutes()
353
+	protected function setupRoutes(): array
351 354
 	{
352 355
 		$routeType = $this->getController();
353 356
 
@@ -359,7 +362,7 @@ final class Dispatcher extends RoutingBase {
359 362
 			unset($route['path']);
360 363
 
361 364
 			$controllerMap = $this->getControllerList();
362
-			$controllerClass = (array_key_exists($routeType, $controllerMap))
365
+			$controllerClass = array_key_exists($routeType, $controllerMap)
363 366
 				? $controllerMap[$routeType]
364 367
 				: DEFAULT_CONTROLLER;
365 368
 

+ 10
- 17
src/FormGenerator.php View File

@@ -16,35 +16,28 @@
16 16
 
17 17
 namespace Aviat\AnimeClient;
18 18
 
19
-use Aviat\Ion\
20
-{
21
-	ArrayWrapper, StringWrapper
22
-};
23 19
 use Aviat\Ion\Di\ContainerInterface;
24 20
 
25 21
 /**
26 22
  * Helper object to manage form generation, especially for config editing
27 23
  */
28 24
 final class FormGenerator {
29
-	use ArrayWrapper;
30
-	use StringWrapper;
31
-
32
-	/**
33
-	 * Injection Container
34
-	 * @var ContainerInterface $container
35
-	 */
36
-	protected $container;
37
-
38 25
 	/**
39 26
 	 * Html generation helper
40 27
 	 *
41 28
 	 * @var \Aura\Html\HelperLocator
42 29
 	 */
43
-	protected $helper;
30
+	private $helper;
44 31
 
32
+	/**
33
+	 * FormGenerator constructor.
34
+	 *
35
+	 * @param ContainerInterface $container
36
+	 * @throws \Aviat\Ion\Di\Exception\ContainerException
37
+	 * @throws \Aviat\Ion\Di\Exception\NotFoundException
38
+	 */
45 39
 	public function __construct(ContainerInterface $container)
46 40
 	{
47
-		$this->container = $container;
48 41
 		$this->helper = $container->get('html-helper');
49 42
 	}
50 43
 
@@ -55,7 +48,7 @@ final class FormGenerator {
55 48
 	 * @param array $form
56 49
 	 * @return string
57 50
 	 */
58
-	public function generate(string $name, array $form)
51
+	public function generate(string $name, array $form): string
59 52
 	{
60 53
 		$type = $form['type'];
61 54
 
@@ -105,6 +98,6 @@ final class FormGenerator {
105 98
 			}
106 99
 		}
107 100
 
108
-		return $this->helper->input($params);
101
+		return (string)$this->helper->input($params);
109 102
 	}
110 103
 }

+ 4
- 2
src/MenuGenerator.php View File

@@ -45,9 +45,11 @@ final class MenuGenerator extends UrlGenerator {
45 45
 	protected $request;
46 46
 
47 47
 	/**
48
-	 * Create menu generator
48
+	 * MenuGenerator constructor.
49 49
 	 *
50 50
 	 * @param ContainerInterface $container
51
+	 * @throws \Aviat\Ion\Di\Exception\ContainerException
52
+	 * @throws \Aviat\Ion\Di\Exception\NotFoundException
51 53
 	 */
52 54
 	public function __construct(ContainerInterface $container)
53 55
 	{
@@ -106,7 +108,7 @@ final class MenuGenerator extends UrlGenerator {
106 108
 
107 109
 			$link = $this->helper->a($this->url($path), $title);
108 110
 
109
-			$attrs = ($selected)
111
+			$attrs = $selected
110 112
 				? ['class' => 'selected']
111 113
 				: [];
112 114
 

+ 1
- 5
src/Model/API.php View File

@@ -16,14 +16,10 @@
16 16
 
17 17
 namespace Aviat\AnimeClient\Model;
18 18
 
19
-use Aviat\Ion\StringWrapper;
20
-
21 19
 /**
22 20
  * Base model for api interaction
23 21
  */
24 22
 class API {
25
-	use StringWrapper;
26
-
27 23
 	/**
28 24
 	 * Sort the list entries by their title
29 25
 	 *
@@ -31,7 +27,7 @@ class API {
31 27
 	 * @param string $sortKey
32 28
 	 * @return void
33 29
 	 */
34
-	protected function sortByName(array &$array, string $sortKey)
30
+	protected function sortByName(array &$array, string $sortKey): void
35 31
 	{
36 32
 		$sort = [];
37 33
 

+ 2
- 2
src/Model/Anime.php View File

@@ -108,7 +108,7 @@ class Anime extends API {
108 108
 	 * @param string $slug
109 109
 	 * @return AnimeType
110 110
 	 */
111
-	public function getAnime(string $slug)
111
+	public function getAnime(string $slug): AnimeType
112 112
 	{
113 113
 		return $this->kitsuModel->getAnime($slug);
114 114
 	}
@@ -147,7 +147,7 @@ class Anime extends API {
147 147
 		$item = $this->kitsuModel->getListItem($itemId);
148 148
 		$array = $item->toArray();
149 149
 
150
-		if (is_array($array['notes']))
150
+		if (\is_array($array['notes']))
151 151
 		{
152 152
 			$array['notes'] = '';
153 153
 		}

+ 5
- 0
src/Model/AnimeCollection.php View File

@@ -226,6 +226,11 @@ final class AnimeCollection extends Collection {
226 226
 		return $query->fetch(PDO::FETCH_ASSOC);
227 227
 	}
228 228
 
229
+	/**
230
+	 * Get the list of genres from the database
231
+	 *
232
+	 * @return array
233
+	 */
229 234
 	private function getGenresForList(): array
230 235
 	{
231 236
 		$query = $this->db->select('hummingbird_id, genre')

+ 3
- 3
src/Model/Collection.php View File

@@ -83,11 +83,11 @@ class Collection extends DB {
83 83
 
84 84
 		if ( ! empty($filter))
85 85
 		{
86
-			$this->db->where_in('hummingbird_id', $filter);
86
+			$this->db->whereIn('hummingbird_id', $filter);
87 87
 		}
88 88
 
89
-		$query = $this->db->order_by('hummingbird_id')
90
-			->order_by('genre')
89
+		$query = $this->db->orderBy('hummingbird_id')
90
+			->orderBy('genre')
91 91
 			->get();
92 92
 
93 93
 		$output = [];

+ 0
- 3
src/Model/DB.php View File

@@ -17,15 +17,12 @@
17 17
 namespace Aviat\AnimeClient\Model;
18 18
 
19 19
 use Aviat\Ion\Di\{ContainerAware, ContainerInterface};
20
-use Aviat\Ion\{ArrayWrapper, StringWrapper};
21 20
 
22 21
 /**
23 22
  * Base model for database interaction
24 23
  */
25 24
 class DB {
26
-	use ArrayWrapper;
27 25
 	use ContainerAware;
28
-	use StringWrapper;
29 26
 
30 27
 	/**
31 28
 	 * The query builder object

+ 4
- 5
src/Model/Settings.php View File

@@ -41,7 +41,7 @@ final class Settings {
41 41
 		$this->config = $config;
42 42
 	}
43 43
 
44
-	public function getSettings()
44
+	public function getSettings(): array
45 45
 	{
46 46
 		$settings = [
47 47
 			'config' => [],
@@ -66,7 +66,7 @@ final class Settings {
66 66
 		return $settings;
67 67
 	}
68 68
 
69
-	public function getSettingsForm()
69
+	public function getSettingsForm(): array
70 70
 	{
71 71
 		$output = [];
72 72
 
@@ -124,7 +124,7 @@ final class Settings {
124 124
 		return $output;
125 125
 	}
126 126
 
127
-	public function validateSettings(array $settings)
127
+	public function validateSettings(array $settings): array
128 128
 	{
129 129
 		$config = (new Config($settings))->toArray();
130 130
 
@@ -150,7 +150,7 @@ final class Settings {
150 150
 					$looseConfig[$key] = $val;
151 151
 				}
152 152
 			}
153
-			elseif (is_array($val) && ! empty($val))
153
+			elseif (\is_array($val) && ! empty($val))
154 154
 			{
155 155
 				foreach($val as $k => $v)
156 156
 				{
@@ -204,7 +204,6 @@ final class Settings {
204 204
 		{
205 205
 			dump($e);
206 206
 			dump($settings);
207
-			die();
208 207
 			return FALSE;
209 208
 		}
210 209
 

+ 0
- 14
src/RoutingBase.php View File

@@ -59,20 +59,6 @@ class RoutingBase {
59 59
 		$this->routes = $this->config->get('routes');
60 60
 	}
61 61
 
62
-	/**
63
-	 * Retrieve the appropriate value for the routing key
64
-	 *
65
-	 * @param string|int|array $key
66
-	 * @return mixed
67
-	 */
68
-	public function __get($key)
69
-	{
70
-		if ($this->config->has($key))
71
-		{
72
-			return $this->config->get($key);
73
-		}
74
-	}
75
-
76 62
 	/**
77 63
 	 * Get the current url path
78 64
 	 * @throws \Aviat\Ion\Di\ContainerException

+ 4
- 4
src/UrlGenerator.php View File

@@ -47,13 +47,13 @@ class UrlGenerator extends RoutingBase {
47 47
 	/**
48 48
 	 * Get the base url for css/js/images
49 49
 	 *
50
-	 * @param string ...$args
50
+	 * @param string[] $args
51 51
 	 * @return string
52 52
 	 */
53 53
 	public function assetUrl(string ...$args): string
54 54
 	{
55 55
 		$baseUrl = rtrim($this->url(''), '/')
56
-			. $this->__get('asset_path');
56
+			. $this->config->get('asset_path');
57 57
 
58 58
 		array_unshift($args, $baseUrl);
59 59
 
@@ -82,7 +82,7 @@ class UrlGenerator extends RoutingBase {
82 82
 		{
83 83
 			if ( ! array_key_exists($i + 1, $segments))
84 84
 			{
85
-				$segments[$i + 1] = "";
85
+				$segments[$i + 1] = '';
86 86
 			}
87 87
 
88 88
 			$path_segments[$i] = preg_replace('`{.*?}`', $segments[$i + 1], $path_segments[$i]);
@@ -104,7 +104,7 @@ class UrlGenerator extends RoutingBase {
104 104
 	public function defaultUrl(string $type): string
105 105
 	{
106 106
 		$type = trim($type);
107
-		$defaultPath = $this->__get("default_{$type}_list_path");
107
+		$defaultPath = $this->config->get("default_{$type}_list_path");
108 108
 
109 109
 		if ($defaultPath !== NULL)
110 110
 		{

+ 3
- 3
src/Util.php View File

@@ -60,7 +60,7 @@ class Util {
60 60
 	 * @param string $b - Second item to compare
61 61
 	 * @return string
62 62
 	 */
63
-	public static function isSelected($a, $b)
63
+	public static function isSelected(string $a, string $b): string
64 64
 	{
65 65
 		return ($a === $b) ? 'selected' : '';
66 66
 	}
@@ -72,7 +72,7 @@ class Util {
72 72
 	 * @param string $b - Second item to compare
73 73
 	 * @return string
74 74
 	 */
75
-	public static function isNotSelected($a, $b)
75
+	public static function isNotSelected(string $a, string $b): string
76 76
 	{
77 77
 		return ($a !== $b) ? 'selected' : '';
78 78
 	}
@@ -100,7 +100,7 @@ class Util {
100 100
 	 *
101 101
 	 * @throws \Aviat\Ion\Di\ContainerException
102 102
 	 * @throws \Aviat\Ion\Di\NotFoundException
103
-	 * @return boolean
103
+	 * @return bool
104 104
 	 */
105 105
 	public function isFormPage(): bool
106 106
 	{

Loading…
Cancel
Save