Version 5.1 - All the GraphQL #32

Closed
timw4mail wants to merge 1160 commits from develop into master
22 changed files with 59 additions and 59 deletions
Showing only changes of commit af95ac941f - Show all commits

View File

@ -33,7 +33,7 @@ $di = function() {
// Set up json handler for ajax errors // Set up json handler for ajax errors
$jsonHandler = new JsonResponseHandler(); $jsonHandler = new JsonResponseHandler();
$jsonHandler->onlyForAjaxRequests(true); $jsonHandler->onlyForAjaxRequests(TRUE);
$whoops->pushHandler($jsonHandler); $whoops->pushHandler($jsonHandler);
$whoops->register(); $whoops->register();

View File

@ -35,7 +35,7 @@ function _dir()
* @codeCoverageIgnore * @codeCoverageIgnore
* @return void * @return void
*/ */
spl_autoload_register(function ($class) { spl_autoload_register(function($class) {
$class_parts = explode('\\', $class); $class_parts = explode('\\', $class);
$ns_path = SRC_DIR . '/' . implode('/', $class_parts) . ".php"; $ns_path = SRC_DIR . '/' . implode('/', $class_parts) . ".php";

View File

@ -22,7 +22,7 @@ class Config {
* *
* @param array $config_files * @param array $config_files
*/ */
public function __construct(Array $config_files=[]) public function __construct(array $config_files=[])
{ {
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
if (empty($config_files)) if (empty($config_files))

View File

@ -53,7 +53,7 @@ class Controller {
/** /**
* Constructor * Constructor
* *
* @param Container $container * @param ContainerInterface $container
*/ */
public function __construct(ContainerInterface $container) public function __construct(ContainerInterface $container)
{ {
@ -92,7 +92,7 @@ class Controller {
* @param array|object $data * @param array|object $data
* @return string * @return string
*/ */
public function load_partial($view, $template, $data=[]) public function load_partial($view, $template, $data = [])
{ {
$errorHandler = $this->container->get('error-handler'); $errorHandler = $this->container->get('error-handler');
$errorHandler->addDataTable('Template Data', $data); $errorHandler->addDataTable('Template Data', $data);
@ -120,7 +120,7 @@ class Controller {
/** /**
* Render a template with header and footer * Render a template with header and footer
* *
* @param HTMLView $view * @param HtmlView $view
* @param string $template * @param string $template
* @param array|object $data * @param array|object $data
* @return void * @return void
@ -139,7 +139,7 @@ class Controller {
* @param array|object $data * @param array|object $data
* @return void * @return void
*/ */
public function outputHTML($template, $data=[]) public function outputHTML($template, $data = [])
{ {
$view = new HtmlView($this->container); $view = new HtmlView($this->container);
$this->render_full_page($view, $template, $data); $this->render_full_page($view, $template, $data);
@ -151,7 +151,7 @@ class Controller {
* @param mixed $data * @param mixed $data
* @return void * @return void
*/ */
public function outputJSON($data=[]) public function outputJSON($data = [])
{ {
$view = new JsonView($this->container); $view = new JsonView($this->container);
$view->setOutput($data); $view->setOutput($data);
@ -165,7 +165,7 @@ class Controller {
* @param string $type * @param string $type
* @return void * @return void
*/ */
public function redirect($path, $code, $type="anime") public function redirect($path, $code, $type = "anime")
{ {
$url = $this->urlGenerator->full_url($path, $type); $url = $this->urlGenerator->full_url($path, $type);
$http = new HttpView($this->container); $http = new HttpView($this->container);
@ -205,7 +205,7 @@ class Controller {
* @param string $status * @param string $status
* @return void * @return void
*/ */
public function login($status="") public function login($status = "")
{ {
$message = ""; $message = "";

View File

@ -51,7 +51,7 @@ class Anime extends BaseController {
/** /**
* Constructor * Constructor
* *
* @param Container $container * @param ContainerInterface $container
*/ */
public function __construct(ContainerInterface $container) public function __construct(ContainerInterface $container)
{ {
@ -73,7 +73,7 @@ class Anime extends BaseController {
]); ]);
} }
public function index($type="watching", $view='') public function index($type = "watching", $view = '')
{ {
return $this->anime_list($type, $view); return $this->anime_list($type, $view);
} }
@ -136,7 +136,7 @@ class Anime extends BaseController {
/** /**
* Update an anime item * Update an anime item
* *
* @return bool * @return boolean|null
*/ */
public function update() public function update()
{ {

View File

@ -52,7 +52,7 @@ class Collection extends BaseController {
/** /**
* Constructor * Constructor
* *
* @param Container $container * @param ContainerInterface $container
*/ */
public function __construct(ContainerInterface $container) public function __construct(ContainerInterface $container)
{ {
@ -113,11 +113,11 @@ class Collection extends BaseController {
* @param int $id * @param int $id
* @return void * @return void
*/ */
public function form($id=NULL) public function form($id = NULL)
{ {
$action = (is_null($id)) ? "Add" : "Edit"; $action = (is_null($id)) ? "Add" : "Edit";
$this->outputHTML('collection/'. strtolower($action), [ $this->outputHTML('collection/' . strtolower($action), [
'action' => $action, 'action' => $action,
'action_url' => $this->urlGenerator->full_url("collection/" . strtolower($action)), 'action_url' => $this->urlGenerator->full_url("collection/" . strtolower($action)),
'title' => $this->config->whose_list . " Anime Collection · {$action}", 'title' => $this->config->whose_list . " Anime Collection · {$action}",

View File

@ -43,7 +43,7 @@ class Manga extends Controller {
/** /**
* Constructor * Constructor
* *
* @param Container $container * @param ContainerInterface $container
*/ */
public function __construct(ContainerInterface $container) public function __construct(ContainerInterface $container)
{ {
@ -58,7 +58,7 @@ class Manga extends Controller {
]); ]);
} }
public function index($status="all", $view="") public function index($status = "all", $view = "")
{ {
return $this->manga_list($status, $view); return $this->manga_list($status, $view);
} }
@ -66,7 +66,7 @@ class Manga extends Controller {
/** /**
* Update an anime item * Update an anime item
* *
* @return bool * @return boolean|null
*/ */
public function update() public function update()
{ {

View File

@ -63,10 +63,10 @@ class MenuGenerator extends RoutingBase {
$parsed = []; $parsed = [];
foreach($this->menus as $name => $menu) foreach ($this->menus as $name => $menu)
{ {
$parsed[$name] = []; $parsed[$name] = [];
foreach($menu['items'] as $path_name => $partial_path) foreach ($menu['items'] as $path_name => $partial_path)
{ {
$title = $this->string($path_name)->humanize()->titleize(); $title = $this->string($path_name)->humanize()->titleize();
$parsed[$name]['items'][$title] = $this->string($menu['route_prefix'])->append($partial_path); $parsed[$name]['items'][$title] = $this->string($menu['route_prefix'])->append($partial_path);
@ -90,7 +90,7 @@ class MenuGenerator extends RoutingBase {
*/ */
public function generate($menu) public function generate($menu)
{ {
$parsed_config = $this->parse_config(); $parsed_config = $this->parse_config();
$menu_config = $parsed_config[$menu]; $menu_config = $parsed_config[$menu];
// Array of list items to add to the main menu // Array of list items to add to the main menu

View File

@ -29,7 +29,7 @@ class Model {
/** /**
* Constructor * Constructor
* *
* @param Container $container * @param ContainerInterface $container
*/ */
public function __construct(ContainerInterface $container) public function __construct(ContainerInterface $container)
{ {
@ -47,7 +47,7 @@ class Model {
* @param string $type - Anime or Manga, controls cache path * @param string $type - Anime or Manga, controls cache path
* @return string - the frontend path for the cached image * @return string - the frontend path for the cached image
*/ */
public function get_cached_image($api_path, $series_slug, $type="anime") public function get_cached_image($api_path, $series_slug, $type = "anime")
{ {
$api_path = str_replace("jjpg", "jpg", $api_path); $api_path = str_replace("jjpg", "jpg", $api_path);
$path_parts = explode('?', basename($api_path)); $path_parts = explode('?', basename($api_path));
@ -111,7 +111,7 @@ class Model {
private function _resize($path, $width, $height) private function _resize($path, $width, $height)
{ {
$img = new SimpleImage($path); $img = new SimpleImage($path);
$img->resize($width,$height)->save(); $img->resize($width, $height)->save();
} }
} }
// End of BaseModel.php // End of BaseModel.php

View File

@ -37,7 +37,7 @@ class API extends BaseModel {
/** /**
* Constructor * Constructor
* *
* @param Container $container * @param ContainerInterface $container
*/ */
public function __construct(ContainerInterface $container) public function __construct(ContainerInterface $container)
{ {

View File

@ -73,13 +73,13 @@ class Anime extends API {
$data = $this->_get_list_from_api(); $data = $this->_get_list_from_api();
foreach($data as $datum) foreach ($data as $datum)
{ {
$output[$this->const_map[$datum['watching_status']]][] = $datum; $output[$this->const_map[$datum['watching_status']]][] = $datum;
} }
// Sort anime by name // Sort anime by name
foreach($output as &$status_list) foreach ($output as &$status_list)
{ {
$this->sort_by_name($status_list); $this->sort_by_name($status_list);
} }
@ -157,7 +157,7 @@ class Anime extends API {
* @param string $status * @param string $status
* @return array * @return array
*/ */
protected function _get_list_from_api($status="all") protected function _get_list_from_api($status = "all")
{ {
$config = [ $config = [
'allow_redirects' => FALSE 'allow_redirects' => FALSE
@ -171,7 +171,7 @@ class Anime extends API {
$response = $this->client->get("users/{$this->config->hummingbird_username}/library", $config); $response = $this->client->get("users/{$this->config->hummingbird_username}/library", $config);
$output = $this->_check_cache($status, $response); $output = $this->_check_cache($status, $response);
foreach($output as &$row) foreach ($output as &$row)
{ {
$row['anime']['image'] = $this->get_cached_image($row['anime']['image'], $row['anime']['slug'], 'anime'); $row['anime']['image'] = $this->get_cached_image($row['anime']['image'], $row['anime']['slug'], 'anime');
} }
@ -197,7 +197,7 @@ class Anime extends API {
if ($api_data === $cached && file_exists($transformed_cache_file)) if ($api_data === $cached && file_exists($transformed_cache_file))
{ {
return json_decode(file_get_contents($transformed_cache_file),TRUE); return json_decode(file_get_contents($transformed_cache_file), TRUE);
} }
else else
{ {
@ -219,7 +219,7 @@ class Anime extends API {
{ {
$sort = array(); $sort = array();
foreach($array as $key => $item) foreach ($array as $key => $item)
{ {
$sort[$key] = $item['anime']['title']; $sort[$key] = $item['anime']['title'];
} }

View File

@ -29,7 +29,7 @@ class AnimeCollection extends DB {
/** /**
* Constructor * Constructor
* *
* @param Container $container * @param ContainerInterface $container
*/ */
public function __construct(ContainerInterface $container) public function __construct(ContainerInterface $container)
{ {
@ -61,7 +61,7 @@ class AnimeCollection extends DB {
* @param array $filter * @param array $filter
* @return array * @return array
*/ */
public function get_genre_list($filter=[]) public function get_genre_list($filter = [])
{ {
$this->db->select('hummingbird_id, genre') $this->db->select('hummingbird_id, genre')
->from('genre_anime_set_link gl') ->from('genre_anime_set_link gl')
@ -76,7 +76,7 @@ class AnimeCollection extends DB {
$output = []; $output = [];
foreach($query->fetchAll(\PDO::FETCH_ASSOC) as $row) foreach ($query->fetchAll(\PDO::FETCH_ASSOC) as $row)
{ {
$id = $row['hummingbird_id']; $id = $row['hummingbird_id'];
$genre = $row['genre']; $genre = $row['genre'];
@ -109,7 +109,7 @@ class AnimeCollection extends DB {
$collection = []; $collection = [];
foreach($raw_collection as $row) foreach ($raw_collection as $row)
{ {
if (array_key_exists($row['media'], $collection)) if (array_key_exists($row['media'], $collection))
{ {
@ -137,7 +137,7 @@ class AnimeCollection extends DB {
->from('media') ->from('media')
->get(); ->get();
foreach($query->fetchAll(\PDO::FETCH_ASSOC) as $row) foreach ($query->fetchAll(\PDO::FETCH_ASSOC) as $row)
{ {
$output[$row['id']] = $row['type']; $output[$row['id']] = $row['type'];
} }
@ -154,7 +154,7 @@ class AnimeCollection extends DB {
public function get_collection_entry($id) public function get_collection_entry($id)
{ {
$query = $this->db->from('anime_set') $query = $this->db->from('anime_set')
->where('hummingbird_id', (int) $id) ->where('hummingbird_id', (int)$id)
->get(); ->get();
return $query->fetch(\PDO::FETCH_ASSOC); return $query->fetch(\PDO::FETCH_ASSOC);
@ -187,7 +187,7 @@ class AnimeCollection extends DB {
*/ */
public function add($data) public function add($data)
{ {
$anime = (object) $this->anime_model->get_anime($data['id']); $anime = (object)$this->anime_model->get_anime($data['id']);
$this->db->set([ $this->db->set([
'hummingbird_id' => $data['id'], 'hummingbird_id' => $data['id'],
@ -252,7 +252,7 @@ class AnimeCollection extends DB {
$anime = json_decode(file_get_contents("import.json")); $anime = json_decode(file_get_contents("import.json"));
foreach($anime as $item) foreach ($anime as $item)
{ {
$this->db->set([ $this->db->set([
'hummingbird_id' => $item->id, 'hummingbird_id' => $item->id,
@ -287,7 +287,7 @@ class AnimeCollection extends DB {
// Get api information // Get api information
$anime = $this->anime_model->get_anime($anime_id); $anime = $this->anime_model->get_anime($anime_id);
foreach($anime['genres'] as $genre) foreach ($anime['genres'] as $genre)
{ {
// Add genres that don't currently exist // Add genres that don't currently exist
if ( ! in_array($genre['name'], $genres)) if ( ! in_array($genre['name'], $genres))
@ -335,7 +335,7 @@ class AnimeCollection extends DB {
$query = $this->db->select('id, genre') $query = $this->db->select('id, genre')
->from('genres') ->from('genres')
->get(); ->get();
foreach($query->fetchAll(\PDO::FETCH_ASSOC) as $genre) foreach ($query->fetchAll(\PDO::FETCH_ASSOC) as $genre)
{ {
$genres[$genre['id']] = $genre['genre']; $genres[$genre['id']] = $genre['genre'];
} }
@ -344,7 +344,7 @@ class AnimeCollection extends DB {
$query = $this->db->select('hummingbird_id, genre_id') $query = $this->db->select('hummingbird_id, genre_id')
->from('genre_anime_set_link') ->from('genre_anime_set_link')
->get(); ->get();
foreach($query->fetchAll(\PDO::FETCH_ASSOC) as $link) foreach ($query->fetchAll(\PDO::FETCH_ASSOC) as $link)
{ {
if (array_key_exists($link['hummingbird_id'], $links)) if (array_key_exists($link['hummingbird_id'], $links))
{ {
@ -371,7 +371,7 @@ class AnimeCollection extends DB {
{ {
// Get the anime collection // Get the anime collection
$collection = $this->_get_collection(); $collection = $this->_get_collection();
foreach($collection as $anime) foreach ($collection as $anime)
{ {
// Get api information // Get api information
$this->update_genre($anime['hummingbird_id']); $this->update_genre($anime['hummingbird_id']);

View File

@ -26,7 +26,7 @@ class DB extends BaseModel {
/** /**
* Constructor * Constructor
* *
* @param Container $container * @param ContainerInterface $container
*/ */
public function __construct(ContainerInterface $container) public function __construct(ContainerInterface $container)
{ {

View File

@ -65,7 +65,7 @@ class Manga extends API {
{ {
$data = $this->_get_list_from_api(); $data = $this->_get_list_from_api();
foreach($data as $key => &$val) foreach ($data as $key => &$val)
{ {
$this->sort_by_name($val); $this->sort_by_name($val);
} }
@ -87,7 +87,7 @@ class Manga extends API {
return $data; return $data;
} }
private function _get_list_from_api($status="All") private function _get_list_from_api($status = "All")
{ {
$config = [ $config = [
@ -154,7 +154,7 @@ class Manga extends API {
self::COMPLETED => [], self::COMPLETED => [],
]; ];
foreach($data as &$entry) foreach ($data as &$entry)
{ {
$entry['manga']['image'] = $this->get_cached_image($entry['manga']['image'], $entry['manga']['slug'], 'manga'); $entry['manga']['image'] = $this->get_cached_image($entry['manga']['image'], $entry['manga']['slug'], 'manga');
$key = $this->const_map[$entry['reading_status']]; $key = $this->const_map[$entry['reading_status']];
@ -185,7 +185,7 @@ class Manga extends API {
{ {
$sort = array(); $sort = array();
foreach($array as $key => $item) foreach ($array as $key => $item)
{ {
$sort[$key] = $item['manga']['title']; $sort[$key] = $item['manga']['title'];
} }

View File

@ -35,7 +35,7 @@ class Router extends RoutingBase {
/** /**
* Constructor * Constructor
* *
* @param Container $container * @param ContainerInterface $container
*/ */
public function __construct(ContainerInterface $container) public function __construct(ContainerInterface $container)
{ {

View File

@ -32,7 +32,7 @@ class RoutingBase {
/** /**
* Constructor * Constructor
* *
* @param Container $container * @param ContainerInterface $container
*/ */
public function __construct(ContainerInterface $container) public function __construct(ContainerInterface $container)
{ {

View File

@ -43,7 +43,7 @@ class MangaListsZipper {
$output = []; $output = [];
foreach($this->manga_tracking_list as &$entry) foreach ($this->manga_tracking_list as &$entry)
{ {
$id = $entry['manga_id']; $id = $entry['manga_id'];
$entry['manga'] = $this->manga_series_list[$id]; $entry['manga'] = $this->manga_series_list[$id];
@ -65,7 +65,7 @@ class MangaListsZipper {
$orig_list = $this->manga_series_list; $orig_list = $this->manga_series_list;
$indexed_list = []; $indexed_list = [];
foreach($orig_list as $manga) foreach ($orig_list as $manga)
{ {
$id = $manga['id']; $id = $manga['id'];
$indexed_list[$id] = $manga; $indexed_list[$id] = $manga;

View File

@ -32,7 +32,7 @@ class UrlGenerator extends RoutingBase {
* @param string $type - (optional) The controller * @param string $type - (optional) The controller
* @return string * @return string
*/ */
public function base_url($type="anime") public function base_url($type = "anime")
{ {
$config_path = trim($this->__get("{$type}_path"), "/"); $config_path = trim($this->__get("{$type}_path"), "/");
@ -88,7 +88,7 @@ class UrlGenerator extends RoutingBase {
* @param string $type - (optional) The controller (anime or manga), defaults to anime * @param string $type - (optional) The controller (anime or manga), defaults to anime
* @return string * @return string
*/ */
public function full_url($path="", $type="anime") public function full_url($path = "", $type = "anime")
{ {
$config_path = trim($this->__get("{$type}_path"), "/"); $config_path = trim($this->__get("{$type}_path"), "/");
$config_default_route = $this->__get("default_{$type}_path"); $config_default_route = $this->__get("default_{$type}_path");

View File

@ -23,7 +23,7 @@ class Container implements ContainerInterface {
*/ */
public function __construct(array $values = []) public function __construct(array $values = [])
{ {
$this->container = new ArrayObject($values); $this->container = new ArrayObject($values);
} }
/** /**

View File

@ -99,7 +99,7 @@ class Friend {
$property->setAccessible(TRUE); $property->setAccessible(TRUE);
return $property; return $property;
} }
catch(\Exception $e) {} catch (\Exception $e) {}
return NULL; return NULL;
} }

View File

@ -22,7 +22,7 @@ abstract class AbstractTransformer implements TransformerInterface {
*/ */
public function transform_collection($collection) public function transform_collection($collection)
{ {
$list = (array) $collection; $list = (array)$collection;
return array_map([$this, 'transform'], $list); return array_map([$this, 'transform'], $list);
} }
} }

View File

@ -59,7 +59,7 @@ class ArrayType {
* *
* @param array $arr * @param array $arr
*/ */
public function __construct(Array $arr) public function __construct(array $arr)
{ {
$this->arr =& $arr; $this->arr =& $arr;
} }