And more snake case to camel case

This commit is contained in:
Timothy Warren 2017-02-15 16:30:14 -05:00
parent b902464446
commit 365da603fa
18 changed files with 76 additions and 75 deletions

View File

@ -1,4 +1,4 @@
<?php if ($auth->is_authenticated()): ?>
<?php if ($auth->isAuthenticated()): ?>
<main>
<h2>Add Anime to your List</h2>
<form action="<?= $action_url ?>" method="post">

View File

@ -1,5 +1,5 @@
<main>
<?php if ($auth->is_authenticated()): ?>
<?php if ($auth->isAuthenticated()): ?>
<a class="bracketed" href="<?= $url->generate('anime.add.get') ?>">Add Item</a>
<?php endif ?>
<?php if (empty($sections)): ?>
@ -10,9 +10,9 @@
<h2><?= $escape->html($name) ?></h2>
<section class="media-wrap">
<?php foreach($items as $item): ?>
<?php if ($item['private'] && ! $auth->is_authenticated()) continue; ?>
<?php if ($item['private'] && ! $auth->isAuthenticated()) continue; ?>
<article class="media" data-kitsu-id="<?= $item['id'] ?>" data-mal-id="<?= $item['mal_id'] ?>">
<?php if ($auth->is_authenticated()): ?>
<?php if ($auth->isAuthenticated()): ?>
<button title="Increment episode count" class="plus_one" hidden>+1 Episode</button>
<?php endif ?>
<img src="<?= $item['anime']['image'] ?>" alt="" />
@ -25,7 +25,7 @@
</a>
</div>
<div class="table">
<?php if ($auth->is_authenticated()): ?>
<?php if ($auth->isAuthenticated()): ?>
<div class="row">
<span class="edit">
<a class="bracketed" title="Edit information about this anime" href="<?= $urlGenerator->url("anime/edit/{$item['id']}/{$item['watching_status']}") ?>">Edit</a>
@ -85,6 +85,6 @@
<?php endforeach ?>
<?php endif ?>
</main>
<?php if ($auth->is_authenticated()): ?>
<?php if ($auth->isAuthenticated()): ?>
<script defer="defer" src="<?= $urlGenerator->assetUrl('js.php/g/edit') ?>"></script>
<?php endif ?>

View File

@ -1,4 +1,4 @@
<?php if ($auth->is_authenticated()): ?>
<?php if ($auth->isAuthenticated()): ?>
<main>
<h2>Edit Anime List Item</h2>
<form action="<?= $action ?>" method="post">

View File

@ -1,5 +1,5 @@
<main>
<?php if ($auth->is_authenticated()): ?>
<?php if ($auth->isAuthenticated()): ?>
<a class="bracketed" href="<?= $url->generate('anime.add.get') ?>">Add Item</a>
<?php endif ?>
<?php if (empty($sections)): ?>
@ -10,7 +10,7 @@
<table>
<thead>
<tr>
<?php if($auth->is_authenticated()): ?>
<?php if($auth->isAuthenticated()): ?>
<td class="no_border">&nbsp;</td>
<?php endif ?>
<th>Title</th>
@ -26,9 +26,9 @@
</thead>
<tbody>
<?php foreach($items as $item): ?>
<?php if ($item['private'] && ! $auth->is_authenticated()) continue; ?>
<?php if ($item['private'] && ! $auth->isAuthenticated()) continue; ?>
<tr id="a-<?= $item['id'] ?>">
<?php if ($auth->is_authenticated()): ?>
<?php if ($auth->isAuthenticated()): ?>
<td>
<a class="bracketed" href="<?= $urlGenerator->url("/anime/edit/{$item['id']}/{$item['watching_status']}") ?>">Edit</a>
</td>
@ -86,5 +86,5 @@
<?php endforeach ?>
<?php endif ?>
</main>
<?php $group = ($auth->is_authenticated()) ? 'table_edit' : 'table' ?>
<?php $group = ($auth->isAuthenticated()) ? 'table_edit' : 'table' ?>
<script defer="defer" src="<?= $urlGenerator->assetUrl("js.php/g/{$group}") ?>"></script>

View File

@ -1,4 +1,4 @@
<?php if ($auth->is_authenticated()): ?>
<?php if ($auth->isAuthenticated()): ?>
<main>
<h2>Add Anime to your Collection</h2>
<form action="<?= $action_url ?>" method="post">

View File

@ -1,5 +1,5 @@
<main>
<?php if ($auth->is_authenticated()): ?>
<?php if ($auth->isAuthenticated()): ?>
<a class="bracketed" href="<?= $url->generate('collection.add.get') ?>">Add Item</a>
<?php endif ?>
<?php if (empty($sections)): ?>
@ -19,7 +19,7 @@
</a>
</div>
<div class="table">
<?php if ($auth->is_authenticated()): ?>
<?php if ($auth->isAuthenticated()): ?>
<div class="row">
<span class="edit"><a class="bracketed" href="<?= $urlGenerator->url("collection/edit/{$item['hummingbird_id']}") ?>">Edit</a></span>
<?php /*<span class="delete"><a class="bracketed" href="<?= $urlGenerator->url("collection/delete/{$item['hummingbird_id']}") ?>">Delete</a></span> */ ?>

View File

@ -1,4 +1,4 @@
<?php if ($auth->is_authenticated()): ?>
<?php if ($auth->isAuthenticated()): ?>
<main>
<h2>Edit Anime Collection Item</h2>
<form action="<?= $action_url ?>" method="post">

View File

@ -1,5 +1,5 @@
<main>
<?php if ($auth->is_authenticated()): ?>
<?php if ($auth->isAuthenticated()): ?>
<a class="bracketed" href="<?= $urlGenerator->fullUrl('collection/add', 'anime') ?>">Add Item</a>
<?php endif ?>
<?php if (empty($sections)): ?>
@ -10,7 +10,7 @@
<table>
<thead>
<tr>
<?php if($auth->is_authenticated()): ?>
<?php if($auth->isAuthenticated()): ?>
<th>Actions</th>
<?php endif ?>
<th>Title</th>
@ -24,7 +24,7 @@
<tbody>
<?php foreach($items as $item): ?>
<tr>
<?php if($auth->is_authenticated()): ?>
<?php if($auth->isAuthenticated()): ?>
<td>
<a class="bracketed" href="<?= $urlGenerator->fullUrl("collection/edit/{$item['hummingbird_id']}") ?>">Edit</a>
<?php /*<a class="bracketed" href="<?= $urlGenerator->fullUrl("collection/delete/{$item['hummingbird_id']}") ?>">Delete</a>*/ ?>

View File

@ -17,7 +17,7 @@
[<a href="<?= $urlGenerator->defaultUrl('manga') ?>">Manga List</a>]
<?php endif ?>
</span>
<?php if ($auth->is_authenticated()): ?>
<?php if ($auth->isAuthenticated()): ?>
<span class="flex-no-wrap">&nbsp;</span>
<span class="flex-no-wrap small-font">
<button type="button" class="js-clear-cache user-btn">Clear API Cache</button>
@ -25,7 +25,7 @@
<span class="flex-no-wrap">&nbsp;</span>
<?php endif ?>
<span class="flex-no-wrap small-font">
<?php if ($auth->is_authenticated()): ?>
<?php if ($auth->isAuthenticated()): ?>
<a class="bracketed" href="<?= $url->generate('logout') ?>">Logout</a>
<?php else: ?>
[<a href="<?= $url->generate('login'); ?>"><?= $config->get('whose_list') ?>'s Login</a>]
@ -37,8 +37,8 @@
<?= $helper->menu($menu_name) ?>
<br />
<ul>
<li class="<?= Util::is_not_selected('list', $urlGenerator->last_segment()) ?>"><a href="<?= $urlGenerator->url($route_path) ?>">Cover View</a></li>
<li class="<?= Util::is_selected('list', $urlGenerator->last_segment()) ?>"><a href="<?= $urlGenerator->url("{$route_path}/list") ?>">List View</a></li>
<li class="<?= Util::is_not_selected('list', $urlGenerator->lastSegment()) ?>"><a href="<?= $urlGenerator->url($route_path) ?>">Cover View</a></li>
<li class="<?= Util::is_selected('list', $urlGenerator->lastSegment()) ?>"><a href="<?= $urlGenerator->url("{$route_path}/list") ?>">List View</a></li>
</ul>
<?php endif ?>
</nav>

View File

@ -1,4 +1,4 @@
<?php if ($auth->is_authenticated()): ?>
<?php if ($auth->isAuthenticated()): ?>
<main>
<h2>Add Manga to your List</h2>
<form action="<?= $action_url ?>" method="post">

View File

@ -1,5 +1,5 @@
<main>
<?php if ($auth->is_authenticated()): ?>
<?php if ($auth->isAuthenticated()): ?>
<a class="bracketed" href="<?= $urlGenerator->url('manga/add') ?>">Add Item</a>
<?php endif ?>
<?php if (empty($sections)): ?>
@ -11,7 +11,7 @@
<section class="media-wrap">
<?php foreach($items as $item): ?>
<article class="media" id="manga-<?= $item['id'] ?>">
<?php if ($auth->is_authenticated()): ?>
<?php if ($auth->isAuthenticated()): ?>
<div class="edit_buttons" hidden>
<button class="plus_one_chapter">+1 Chapter</button>
</div>
@ -26,7 +26,7 @@
</a>
</div>
<div class="table">
<?php if ($auth->is_authenticated()): ?>
<?php if ($auth->isAuthenticated()): ?>
<div class="row">
<span class="edit">
<a class="bracketed" title="Edit information about this manga" href="<?= $urlGenerator->url("manga/edit/{$item['id']}/{$name}") ?>">Edit</a>
@ -55,6 +55,6 @@
<?php endforeach ?>
<?php endif ?>
</main>
<?php if ($auth->is_authenticated()): ?>
<?php if ($auth->isAuthenticated()): ?>
<script defer="defer" src="<?= $urlGenerator->assetUrl('js.php/g/edit') ?>"></script>
<?php endif ?>

View File

@ -1,4 +1,4 @@
<?php if ($auth->is_authenticated()): ?>
<?php if ($auth->isAuthenticated()): ?>
<main>
<h1>
Edit <?= $item['manga']['titles'][0] ?>

View File

@ -1,5 +1,5 @@
<main>
<?php if ($auth->is_authenticated()): ?>
<?php if ($auth->isAuthenticated()): ?>
<a class="bracketed" href="<?= $urlGenerator->url('manga/add') ?>">Add Item</a>
<?php endif ?>
<?php if (empty($sections)): ?>
@ -10,7 +10,7 @@
<table>
<thead>
<tr>
<?php if ($auth->is_authenticated()): ?>
<?php if ($auth->isAuthenticated()): ?>
<th>&nbsp;</th>
<?php endif ?>
<th>Title</th>
@ -23,7 +23,7 @@
<tbody>
<?php foreach($items as $item): ?>
<tr id="manga-<?= $item['id'] ?>">
<?php if($auth->is_authenticated()): ?>
<?php if($auth->isAuthenticated()): ?>
<td>
<a class="bracketed" href="<?= $urlGenerator->url("manga/edit/{$item['id']}/{$name}") ?>">Edit</a>
</td>

View File

@ -102,7 +102,7 @@ class Auth {
*
* @return boolean
*/
public function is_authenticated()
public function isAuthenticated()
{
return ($this->get_auth_token() !== FALSE);
}

View File

@ -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 &middot; {$type_title_map[$type]}"
"'s Anime List &middot; {$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
]);

View File

@ -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');
}
}
}

View File

@ -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);

View File

@ -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");
}
}
}