More code styles fixes

This commit is contained in:
Timothy Warren 2017-02-15 15:35:41 -05:00
parent 1224882092
commit 29c04e62be
7 changed files with 51 additions and 55 deletions

View File

@ -122,7 +122,7 @@ class Anime extends BaseController {
*
* @return void
*/
public function add_form()
public function addForm()
{
$statuses = [
AnimeWatchingStatus::WATCHING => 'Currently Watching',
@ -220,17 +220,17 @@ class Anime extends BaseController {
*
* @return void
*/
public function form_update()
public function formUpdate()
{
$data = $this->request->getParsedBody();
// Do some minor data manipulation for
// large form-based updates
$transformer = new AnimeListTransformer();
$post_data = $transformer->untransform($data);
$full_result = $this->model->updateLibraryItem($post_data);
$postData = $transformer->untransform($data);
$fullResult = $this->model->updateLibraryItem($postData);
if ($full_result['statusCode'] === 200)
if ($fullResult['statusCode'] === 200)
{
$this->set_flash_message("Successfully updated.", 'success');
$this->cache->clear();
@ -291,12 +291,12 @@ class Anime extends BaseController {
/**
* View details of an anime
*
* @param string $anime_id
* @param string $animeId
* @return void
*/
public function details($anime_id)
public function details($animeId)
{
$data = $this->model->getAnime($anime_id);
$data = $this->model->getAnime($animeId);
$this->outputHTML('anime/details', [
'title' => 'Anime &middot ' . $data['titles'][0],

View File

@ -91,17 +91,17 @@ class Collection extends BaseController {
*/
public function index($view)
{
$view_map = [
$viewMap = [
'' => 'cover',
'list' => 'list'
];
$data = $this->animeCollectionModel->get_collection();
$data = $this->animeCollectionModel->getCollection();
$this->outputHTML('collection/' . $view_map[$view], [
$this->outputHTML('collection/' . $viewMap[$view], [
'title' => $this->config->get('whose_list') . "'s Anime Collection",
'sections' => $data,
'genres' => $this->animeCollectionModel->get_genre_list()
'genres' => $this->animeCollectionModel->getGenreList()
]);
}

View File

@ -101,7 +101,7 @@ class Manga extends Controller {
*
* @return void
*/
public function add_form()
public function addForm()
{
$raw_status_list = MangaReadingStatus::getConstList();
@ -190,7 +190,7 @@ class Manga extends Controller {
*
* @return void
*/
public function form_update()
public function formUpdate()
{
$data = $this->request->getParsedBody();

View File

@ -31,9 +31,9 @@ class AnimeCollection extends Collection {
*
* @return array
*/
public function get_collection()
public function getCollection()
{
$raw_collection = $this->_get_collection();
$raw_collection = $this->_getCollection();
$collection = [];
@ -57,7 +57,7 @@ class AnimeCollection extends Collection {
*
* @return array
*/
public function get_media_type_list()
public function getMediaTypeList()
{
$output = [];
@ -79,7 +79,7 @@ class AnimeCollection extends Collection {
* @param int $id
* @return array
*/
public function get_collection_entry($id)
public function getCollectionEntry($id)
{
$query = $this->db->from('anime_set')
->where('hummingbird_id', (int)$id)
@ -93,9 +93,9 @@ class AnimeCollection extends Collection {
*
* @return array
*/
private function _get_collection()
private function _getCollection()
{
if ( ! $this->valid_database)
if ( ! $this->validDatabase)
{
return [];
}
@ -119,7 +119,7 @@ class AnimeCollection extends Collection {
*/
public function add($data)
{
$anime = (object)$this->anime_model->getAnimeById($data['id']);
$anime = (object)$this->animeModel->getAnimeById($data['id']);
$this->db->set([
'hummingbird_id' => $data['id'],
'slug' => $anime->slug,
@ -134,7 +134,7 @@ class AnimeCollection extends Collection {
'notes' => $data['notes']
])->insert('anime_set');
$this->update_genre($data['id']);
$this->updateGenre($data['id']);
}
/**
@ -201,13 +201,13 @@ class AnimeCollection extends Collection {
* @param int $anime_id The current anime
* @return void
*/
private function update_genre($anime_id)
private function updateGenre($anime_id)
{
$genre_info = $this->get_genre_data();
$genre_info = $this->getGenreData();
extract($genre_info);
// Get api information
$anime = $this->anime_model->getAnimeById($anime_id);
$anime = $this->animeModel->getAnimeById($anime_id);
foreach ($anime['genres'] as $genre)
{
@ -248,7 +248,7 @@ class AnimeCollection extends Collection {
*
* @return array
*/
private function get_genre_data()
private function getGenreData()
{
$genres = [];
$links = [];

View File

@ -16,10 +16,8 @@
namespace Aviat\AnimeClient\Model;
use Aviat\Ion\Di\ContainerAware;
use Aviat\Ion\Di\ContainerInterface;
use Aviat\Ion\Model\DB;
use Aviat\AnimeClient\Model\DB;
use Aviat\Ion\Di\{ContainerAware, ContainerInterface};
use PDO;
use PDOException;
@ -32,15 +30,15 @@ class Collection extends DB {
/**
* Anime API Model
* @var object $anime_model
* @var object $animeModel
*/
protected $anime_model;
protected $animeModel;
/**
* Whether the database is valid for querying
* @var boolean
*/
protected $valid_database = FALSE;
protected $validDatabase = FALSE;
/**
* Create a new collection object
@ -49,40 +47,38 @@ class Collection extends DB {
*/
public function __construct(ContainerInterface $container)
{
$this->container = $container;
parent::__construct($container->get('config'));
parent::__construct($container);
try
{
$this->db = \Query($this->db_config['collection']);
$this->db = \Query($this->dbConfig['collection']);
}
catch (PDOException $e)
{
//$this->valid_database = FALSE;
//$this->validDatabase = FALSE;
//return FALSE;
}
$this->anime_model = $container->get('anime-model');
$this->animeModel = $container->get('anime-model');
// Is database valid? If not, set a flag so the
// app can be run without a valid database
if ($this->db_config['collection']['type'] === 'sqlite')
if ($this->dbConfig['collection']['type'] === 'sqlite')
{
$db_file_name = $this->db_config['collection']['file'];
$dbFileName = $this->dbConfig['collection']['file'];
if ($db_file_name !== ':memory:' && file_exists($db_file_name))
if ($dbFileName !== ':memory:' && file_exists($dbFileName))
{
$db_file = file_get_contents($db_file_name);
$this->valid_database = (strpos($db_file, 'SQLite format 3') === 0);
$dbFile = file_get_contents($dbFileName);
$this->validDatabase = (strpos($dbFile, 'SQLite format 3') === 0);
}
else
{
$this->valid_database = FALSE;
$this->validDatabase = FALSE;
}
}
else
{
$this->valid_database = TRUE;
$this->validDatabase = TRUE;
}
}
@ -92,7 +88,7 @@ class Collection extends DB {
* @param array $filter
* @return array
*/
public function get_genre_list($filter = [])
public function getGenreList($filter = [])
{
$this->db->select('hummingbird_id, genre')
->from('genre_anime_set_link gl')

View File

@ -16,14 +16,14 @@
namespace Aviat\AnimeClient\Model;
use Aviat\Ion\Di\ContainerInterface;
use Aviat\Ion\Di\{ContainerAware, ContainerInterface};
use Aviat\Ion\Model;
/**
* Base model for database interaction
*/
class DB extends Model {
use \Aviat\Ion\Di\ContainerAware;
use ContainerAware;
/**
* The query builder object
@ -33,9 +33,9 @@ class DB extends Model {
/**
* The database connection information array
* @var array $db_config
* @var array $dbConfig
*/
protected $db_config;
protected $dbConfig = [];
/**
* Constructor
@ -44,7 +44,7 @@ class DB extends Model {
*/
public function __construct(ContainerInterface $container)
{
$this->db_config = $container->get('config')->get('database');
$this->dbConfig = $container->get('config')->get('database');
$this->setContainer($container);
}
}

View File

@ -199,7 +199,7 @@ class DispatcherTest extends AnimeClient_TestCase {
public function dataGetControllerList()
{
return array(
return [
'controller_list_sanity_check' => [
'config' => [
'routes' => [
@ -242,7 +242,7 @@ class DispatcherTest extends AnimeClient_TestCase {
'collection' => 'Aviat\AnimeClient\Controller\Collection',
]
]
);
];
}
/**