Remove some dead code

This commit is contained in:
Timothy Warren 2015-10-12 14:11:00 -04:00
parent 725915060b
commit 6b1f39525d
10 changed files with 36 additions and 104 deletions

View File

@ -34,7 +34,6 @@ class Manga extends Controller {
public function __construct(ContainerInterface $container)
{
parent::__construct($container);
$config = $container->get('config');
$this->model = new MangaModel($container);
$this->base_data = array_merge($this->base_data, [
'menu_name' => 'manga_list',

View File

@ -1,11 +0,0 @@
<?php
namespace Aviat\AnimeClient\Controller;
use Aviat\Ion\Di\ContainerInterface;
use Aviat\AnimeClient\Controller;
class Stats extends Controller {
}
// End of Stats.php

View File

@ -53,16 +53,6 @@ class MenuGenerator extends UrlGenerator {
*/
protected function parse_config()
{
// Note: Children menus have urls based on the
// current url path
/*
parsed = {
menu_name: {
title: 'full_url_path'
}
}
*/
$parsed = [];
foreach ($this->menus as $name => $menu)

View File

@ -68,11 +68,7 @@ class Model {
// Cache the file if it doesn't already exist
if ( ! file_exists($cached_path))
{
/*if (ini_get('allow_url_fopen'))
{
copy($api_path, $cached_path);
}
else*/if (function_exists('curl_init'))
if (function_exists('curl_init'))
{
$ch = curl_init($api_path);
$fp = fopen($cached_path, 'wb');
@ -84,6 +80,10 @@ class Model {
curl_close($ch);
fclose($fp);
}
else if (ini_get('allow_url_fopen'))
{
copy($api_path, $cached_path);
}
else
{
throw new DomainException("Couldn't cache images because they couldn't be downloaded.");

View File

@ -99,7 +99,7 @@ class Manga extends API {
];
$response = $this->client->get('manga_library_entries', $config);
$data = $this->_check_cache($status, $response);
$data = $this->_check_cache($response);
$output = $this->map_by_status($data);
return (array_key_exists($status, $output)) ? $output[$status] : $output;
@ -108,11 +108,10 @@ class Manga extends API {
/**
* Check the status of the cache and return the appropriate response
*
* @param string $status
* @param \GuzzleHttp\Message\Response $response
* @return array
*/
private function _check_cache($status, $response)
private function _check_cache($response)
{
// Bail out early if there isn't any manga data
$api_data = json_decode($response->getBody(), TRUE);

View File

@ -1,30 +0,0 @@
<?php
/**
* Anime API Model
*/
namespace Aviat\AnimeClient\Model;
use Avait\Ion\Di\ContainerInterface;
use Aviat\AnimeClient\Model\DB;
/**
* Base Model for stats about lists and collection(s)
*/
class Stats extends DB {
use StatsChartsTrait;
/**
* Constructor
*
* @param Container $container
*/
public function __construct(ContainerInterface $container)
{
parent::__construct($container);
$this->chartSetup();
}
}
// End of Stats.php

View File

@ -1,29 +0,0 @@
<?php
namespace Aviat\AnimeClient\Model;
use CpChart\Services\pChartFactory;
/**
* Trait for chart generation
*/
trait StatsChartsTrait {
/**
* @var pChartFactory
*/
protected $pchart;
/**
* Initial setup method
*
* @return void
*/
protected function chartSetup()
{
$this->pchart = new pChartFactory();
}
}
// End of StatsChartsTrait.php

View File

@ -90,7 +90,6 @@ class UrlGenerator extends RoutingBase {
*/
public function full_url($path = "", $type = "anime")
{
$config_path = trim($this->__get("{$type}_path"), "/");
$config_default_route = $this->__get("default_{$type}_path");
// Remove beginning/trailing slashes

View File

@ -248,7 +248,6 @@ class DispatcherTest extends AnimeClient_TestCase {
'anime' => 'Aviat\AnimeClient\Controller\Anime',
'manga' => 'Aviat\AnimeClient\Controller\Manga',
'collection' => 'Aviat\AnimeClient\Controller\Collection',
'stats' => 'Aviat\AnimeClient\Controller\Stats'
]
],
'empty_controller_list' => [

View File

@ -23,13 +23,29 @@ class ArrayTypeTest extends AnimeClient_TestCase {
'keys' => 'array_keys',
'merge' => 'array_merge',
'pad' => 'array_pad',
'product' => 'array_product',
'random' => 'array_rand',
'reduce' => 'array_reduce',
'reverse' => 'array_reverse',
];
return [
'array_merge' => [
'method' => 'merge',
'array' => [1, 3, 5, 7],
'args' => [[2, 4, 6, 8]],
'expected' => [1, 3, 5, 7, 2, 4, 6, 8]
],
'array_product' => [
'method' => 'product',
'array' => [1, 2, 3],
'args' => [],
'expected' => 6
],
'array_reverse' => [
'method' => 'reverse',
'array' => [1, 2, 3, 4, 5],
'args' => [],
'expected' => [5, 4, 3, 2, 1]
],
'array_sum' => [
'method' => 'sum',
'array' => [1, 2, 3, 4, 5, 6],
@ -63,6 +79,16 @@ class ArrayTypeTest extends AnimeClient_TestCase {
$this->assertEquals($expected, $actual);
}
public function testMap()
{
$obj = $this->arr([1, 2, 3]);
$actual = $obj->map(function($item) {
return $item * 2;
});
$this->assertEquals([2, 4, 6], $actual);
}
public function testBadCall()
{
$obj = $this->arr([]);
@ -71,16 +97,6 @@ class ArrayTypeTest extends AnimeClient_TestCase {
$obj->foo();
}
public function testMerge()
{
$obj = $this->arr([1, 3, 5, 7]);
$even_array = [2, 4, 6, 8];
$expected = [1, 3, 5, 7, 2, 4, 6, 8];
$actual = $obj->merge($even_array);
$this->assertEquals($expected, $actual);
}
public function testShuffle()
{
$original = [1, 2, 3, 4];