From 84cb1cb520cb8b1b901263ee820387a83b34e0d7 Mon Sep 17 00:00:00 2001 From: "Timothy J. Warren" Date: Wed, 15 Feb 2017 16:30:14 -0500 Subject: [PATCH] And more snake case to camel case --- app/views/anime/add.php | 2 +- app/views/anime/cover.php | 10 ++++----- app/views/anime/edit.php | 2 +- app/views/anime/list.php | 10 ++++----- app/views/collection/add.php | 2 +- app/views/collection/cover.php | 4 ++-- app/views/collection/edit.php | 2 +- app/views/collection/list.php | 6 +++--- app/views/main-menu.php | 8 +++---- app/views/manga/add.php | 2 +- app/views/manga/cover.php | 8 +++---- app/views/manga/edit.php | 2 +- app/views/manga/list.php | 6 +++--- src/API/Kitsu/Auth.php | 2 +- src/Controller/Anime.php | 14 ++++++------- src/Model/AnimeCollection.php | 38 +++++++++++++++++----------------- src/RoutingBase.php | 25 +++++++++++----------- tests/RoutingBaseTest.php | 8 +++---- 18 files changed, 76 insertions(+), 75 deletions(-) diff --git a/app/views/anime/add.php b/app/views/anime/add.php index 1818fa02..1c039547 100644 --- a/app/views/anime/add.php +++ b/app/views/anime/add.php @@ -1,4 +1,4 @@ -is_authenticated()): ?> +isAuthenticated()): ?>

Add Anime to your List

diff --git a/app/views/anime/cover.php b/app/views/anime/cover.php index 61a1b9b2..51cffb84 100644 --- a/app/views/anime/cover.php +++ b/app/views/anime/cover.php @@ -1,5 +1,5 @@
-is_authenticated()): ?> +isAuthenticated()): ?> Add Item @@ -10,9 +10,9 @@

html($name) ?>

- is_authenticated()) continue; ?> + isAuthenticated()) continue; ?>
- is_authenticated()): ?> + isAuthenticated()): ?> @@ -25,7 +25,7 @@
- is_authenticated()): ?> + isAuthenticated()): ?>
">Edit @@ -85,6 +85,6 @@
-is_authenticated()): ?> +isAuthenticated()): ?> \ No newline at end of file diff --git a/app/views/anime/edit.php b/app/views/anime/edit.php index e01d90f9..3e70adb9 100644 --- a/app/views/anime/edit.php +++ b/app/views/anime/edit.php @@ -1,4 +1,4 @@ -is_authenticated()): ?> +isAuthenticated()): ?>

Edit Anime List Item

diff --git a/app/views/anime/list.php b/app/views/anime/list.php index 4f08e588..f2857e26 100644 --- a/app/views/anime/list.php +++ b/app/views/anime/list.php @@ -1,5 +1,5 @@
-is_authenticated()): ?> +isAuthenticated()): ?> Add Item @@ -10,7 +10,7 @@ - is_authenticated()): ?> + isAuthenticated()): ?> @@ -26,9 +26,9 @@ - is_authenticated()) continue; ?> + isAuthenticated()) continue; ?> - is_authenticated()): ?> + isAuthenticated()): ?> @@ -86,5 +86,5 @@ -is_authenticated()) ? 'table_edit' : 'table' ?> +isAuthenticated()) ? 'table_edit' : 'table' ?> \ No newline at end of file diff --git a/app/views/collection/add.php b/app/views/collection/add.php index 64f472c0..9970cf26 100644 --- a/app/views/collection/add.php +++ b/app/views/collection/add.php @@ -1,4 +1,4 @@ -is_authenticated()): ?> +isAuthenticated()): ?>

Add Anime to your Collection

diff --git a/app/views/collection/cover.php b/app/views/collection/cover.php index 919b2d54..996d246a 100644 --- a/app/views/collection/cover.php +++ b/app/views/collection/cover.php @@ -1,5 +1,5 @@
-is_authenticated()): ?> +isAuthenticated()): ?> Add Item @@ -19,7 +19,7 @@
- is_authenticated()): ?> + isAuthenticated()): ?>
">Edit ">Delete */ ?> diff --git a/app/views/collection/edit.php b/app/views/collection/edit.php index 67bb7bec..ab0f4a53 100644 --- a/app/views/collection/edit.php +++ b/app/views/collection/edit.php @@ -1,4 +1,4 @@ -is_authenticated()): ?> +isAuthenticated()): ?>

Edit Anime Collection Item

diff --git a/app/views/collection/list.php b/app/views/collection/list.php index 71b48d51..0bb4daee 100644 --- a/app/views/collection/list.php +++ b/app/views/collection/list.php @@ -1,5 +1,5 @@
-is_authenticated()): ?> +isAuthenticated()): ?> Add Item @@ -10,7 +10,7 @@
  Title
">Edit
- is_authenticated()): ?> + isAuthenticated()): ?> @@ -24,7 +24,7 @@ - is_authenticated()): ?> + isAuthenticated()): ?>
Actions Title
">Edit fullUrl("collection/delete/{$item['hummingbird_id']}") ?>">Delete*/ ?> diff --git a/app/views/main-menu.php b/app/views/main-menu.php index e7c5c67d..9542d7eb 100644 --- a/app/views/main-menu.php +++ b/app/views/main-menu.php @@ -17,7 +17,7 @@ [Manga List] - is_authenticated()): ?> + isAuthenticated()): ?>   @@ -25,7 +25,7 @@   - is_authenticated()): ?> + isAuthenticated()): ?> Logout [get('whose_list') ?>'s Login] @@ -37,8 +37,8 @@ menu($menu_name) ?>
diff --git a/app/views/manga/add.php b/app/views/manga/add.php index fcda2f2b..f0e32f3e 100644 --- a/app/views/manga/add.php +++ b/app/views/manga/add.php @@ -1,4 +1,4 @@ -is_authenticated()): ?> +isAuthenticated()): ?>

Add Manga to your List

diff --git a/app/views/manga/cover.php b/app/views/manga/cover.php index 4f0e65d2..7f9ebdbd 100644 --- a/app/views/manga/cover.php +++ b/app/views/manga/cover.php @@ -1,5 +1,5 @@
-is_authenticated()): ?> +isAuthenticated()): ?> Add Item @@ -11,7 +11,7 @@
- is_authenticated()): ?> + isAuthenticated()): ?> @@ -26,7 +26,7 @@
- is_authenticated()): ?> + isAuthenticated()): ?>
">Edit @@ -55,6 +55,6 @@
-is_authenticated()): ?> +isAuthenticated()): ?> \ No newline at end of file diff --git a/app/views/manga/edit.php b/app/views/manga/edit.php index a1eef3c4..e74a1331 100644 --- a/app/views/manga/edit.php +++ b/app/views/manga/edit.php @@ -1,4 +1,4 @@ -is_authenticated()): ?> +isAuthenticated()): ?>

Edit diff --git a/app/views/manga/list.php b/app/views/manga/list.php index 506397e6..1c28fdcb 100644 --- a/app/views/manga/list.php +++ b/app/views/manga/list.php @@ -1,5 +1,5 @@
-is_authenticated()): ?> +isAuthenticated()): ?> Add Item @@ -10,7 +10,7 @@ - is_authenticated()): ?> + isAuthenticated()): ?> @@ -23,7 +23,7 @@ - is_authenticated()): ?> + isAuthenticated()): ?> diff --git a/src/API/Kitsu/Auth.php b/src/API/Kitsu/Auth.php index 13039009..c2c3789a 100644 --- a/src/API/Kitsu/Auth.php +++ b/src/API/Kitsu/Auth.php @@ -102,7 +102,7 @@ class Auth { * * @return boolean */ - public function is_authenticated() + public function isAuthenticated() { return ($this->get_auth_token() !== FALSE); } diff --git a/src/Controller/Anime.php b/src/Controller/Anime.php index a452f65b..bda57451 100644 --- a/src/Controller/Anime.php +++ b/src/Controller/Anime.php @@ -79,7 +79,7 @@ class Anime extends BaseController { */ public function index($type = AnimeWatchingStatus::WATCHING, string $view = NULL) { - $type_title_map = [ + $typeTitleMap = [ 'all' => 'All', AnimeWatchingStatus::WATCHING => 'Currently Watching', AnimeWatchingStatus::PLAN_TO_WATCH => 'Plan to Watch', @@ -88,7 +88,7 @@ class Anime extends BaseController { AnimeWatchingStatus::COMPLETED => 'Completed' ]; - $model_map = [ + $modelMap = [ 'watching' => AnimeWatchingStatus::WATCHING, 'plan_to_watch' => AnimeWatchingStatus::PLAN_TO_WATCH, 'on_hold' => AnimeWatchingStatus::ON_HOLD, @@ -97,21 +97,21 @@ class Anime extends BaseController { 'completed' => AnimeWatchingStatus::COMPLETED ]; - $title = (array_key_exists($type, $type_title_map)) + $title = (array_key_exists($type, $typeTitleMap)) ? $this->config->get('whose_list') . - "'s Anime List · {$type_title_map[$type]}" + "'s Anime List · {$typeTitleMap[$type]}" : ''; - $view_map = [ + $viewMap = [ '' => 'cover', 'list' => 'list' ]; $data = ($type !== 'all') - ? $this->model->getList($model_map[$type]) + ? $this->model->getList($modelMap[$type]) : $this->model->get_all_lists(); - $this->outputHTML('anime/' . $view_map[$view], [ + $this->outputHTML('anime/' . $viewMap[$view], [ 'title' => $title, 'sections' => $data ]); diff --git a/src/Model/AnimeCollection.php b/src/Model/AnimeCollection.php index 22fdc8d0..9ae62974 100644 --- a/src/Model/AnimeCollection.php +++ b/src/Model/AnimeCollection.php @@ -33,11 +33,11 @@ class AnimeCollection extends Collection { */ public function getCollection() { - $raw_collection = $this->_getCollection(); + $rawCollection = $this->getCollectionFromDatabase(); $collection = []; - foreach ($raw_collection as $row) + foreach ($rawCollection as $row) { if (array_key_exists($row['media'], $collection)) { @@ -93,7 +93,7 @@ class AnimeCollection extends Collection { * * @return array */ - private function _getCollection() + private function getCollectionFromDatabase() { if ( ! $this->validDatabase) { @@ -183,13 +183,13 @@ class AnimeCollection extends Collection { /** * Get the details of a collection item * - * @param int $hummingbird_id + * @param int $kitsuId * @return array */ - public function get($hummingbird_id) + public function get($kitsuId) { $query = $this->db->from('anime_set') - ->where('hummingbird_id', $hummingbird_id) + ->where('hummingbird_id', $kitsuId) ->get(); return $query->fetch(PDO::FETCH_ASSOC); @@ -198,16 +198,16 @@ class AnimeCollection extends Collection { /** * Update genre information for selected anime * - * @param int $anime_id The current anime + * @param int $animeId The current anime * @return void */ - private function updateGenre($anime_id) + private function updateGenre($animeId) { - $genre_info = $this->getGenreData(); - extract($genre_info); + $genreInfo = $this->getGenreData(); + extract($genreInfo); // Get api information - $anime = $this->animeModel->getAnimeById($anime_id); + $anime = $this->animeModel->getAnimeById($animeId); foreach ($anime['genres'] as $genre) { @@ -222,23 +222,23 @@ class AnimeCollection extends Collection { // Update link table // Get id of genre to put in link table - $flipped_genres = array_flip($genres); + $flippedGenres = array_flip($genres); - $insert_array = [ - 'hummingbird_id' => $anime_id, - 'genre_id' => $flipped_genres[$genre] + $insertArray = [ + 'hummingbird_id' => $animeId, + 'genre_id' => $flippedGenres[$genre] ]; - if (array_key_exists($anime_id, $links)) + if (array_key_exists($animeId, $links)) { - if ( ! in_array($flipped_genres[$genre], $links[$anime_id])) + if ( ! in_array($flippedGenres[$genre], $links[$animeId])) { - $this->db->set($insert_array)->insert('genre_anime_set_link'); + $this->db->set($insertArray)->insert('genre_anime_set_link'); } } else { - $this->db->set($insert_array)->insert('genre_anime_set_link'); + $this->db->set($insertArray)->insert('genre_anime_set_link'); } } } diff --git a/src/RoutingBase.php b/src/RoutingBase.php index 2a1f479a..79cde788 100644 --- a/src/RoutingBase.php +++ b/src/RoutingBase.php @@ -17,13 +17,14 @@ namespace Aviat\AnimeClient; use Aviat\Ion\Di\ContainerInterface; +use Aviat\Ion\StringWrapper; /** * Base for routing/url classes */ class RoutingBase { - use \Aviat\Ion\StringWrapper; + use StringWrapper; /** * Injection Container @@ -47,7 +48,7 @@ class RoutingBase { * Route configuration options * @var array */ - protected $route_config; + protected $routeConfig; /** * Constructor @@ -58,9 +59,9 @@ class RoutingBase { { $this->container = $container; $this->config = $container->get('config'); - $base_routes = $this->config->get('routes'); - $this->routes = $base_routes['routes']; - $this->route_config = $base_routes['route_config']; + $baseRoutes = $this->config->get('routes'); + $this->routes = $baseRoutes['routes']; + $this->routeConfig = $baseRoutes['route_config']; } /** @@ -71,11 +72,11 @@ class RoutingBase { */ public function __get($key) { - $routing_config =& $this->route_config; + $routingConfig =& $this->routeConfig; - if (array_key_exists($key, $routing_config)) + if (array_key_exists($key, $routingConfig)) { - return $routing_config[$key]; + return $routingConfig[$key]; } } @@ -88,13 +89,13 @@ class RoutingBase { { $request = $this->container->get('request'); $path = $request->getUri()->getPath(); - $cleaned_path = $this->string($path) + $cleanedPath = $this->string($path) ->replace('%20', '') ->trim() ->trimRight('/') ->ensureLeft('/'); - return (string)$cleaned_path; + return (string)$cleanedPath; } /** @@ -114,7 +115,7 @@ class RoutingBase { * @param int $num * @return string|null */ - public function get_segment($num) + public function getSegment($num) { $segments = $this->segments(); return (array_key_exists($num, $segments)) ? $segments[$num] : NULL; @@ -125,7 +126,7 @@ class RoutingBase { * * @return string */ - public function last_segment() + public function lastSegment() { $segments = $this->segments(); return end($segments); diff --git a/tests/RoutingBaseTest.php b/tests/RoutingBaseTest.php index 77ed9965..0ebd85aa 100644 --- a/tests/RoutingBaseTest.php +++ b/tests/RoutingBaseTest.php @@ -19,13 +19,13 @@ class RoutingBaseTest extends AnimeClient_TestCase { 'requestUri' => ' // ', 'path' => '/', 'segments' => ['', ''], - 'last_segment' => NULL + 'lastSegment' => NULL ], 'three_segments' => [ 'requestUri' => '/anime/watching/list ', 'path' => '/anime/watching/list', 'segments' => ['', 'anime', 'watching', 'list'], - 'last_segment' => 'list' + 'lastSegment' => 'list' ] ]; } @@ -43,11 +43,11 @@ class RoutingBaseTest extends AnimeClient_TestCase { $this->assertEquals($path, $this->routingBase->path(), "Path is invalid"); $this->assertEquals($segments, $this->routingBase->segments(), "Segments array is invalid"); - $this->assertEquals($lastSegment, $this->routingBase->last_segment(), "Last segment is invalid"); + $this->assertEquals($lastSegment, $this->routingBase->lastSegment(), "Last segment is invalid"); foreach($segments as $i => $value) { - $this->assertEquals($value, $this->routingBase->get_segment($i), "Segment {$i} is invalid"); + $this->assertEquals($value, $this->routingBase->getSegment($i), "Segment {$i} is invalid"); } } } \ No newline at end of file
  Title
">Edit