From bc6aed51c8b9b5e26c6d4dbd58e27f0bf69e211a Mon Sep 17 00:00:00 2001 From: "Timothy J. Warren" Date: Mon, 12 Oct 2015 14:11:00 -0400 Subject: [PATCH] Remove some dead code --- src/Aviat/AnimeClient/Controller/Manga.php | 1 - src/Aviat/AnimeClient/Controller/Stats.php | 11 ----- src/Aviat/AnimeClient/MenuGenerator.php | 10 ----- src/Aviat/AnimeClient/Model.php | 10 ++--- src/Aviat/AnimeClient/Model/Manga.php | 5 +-- src/Aviat/AnimeClient/Model/Stats.php | 30 ------------- .../AnimeClient/Model/StatsChartsTrait.php | 29 ------------- src/Aviat/AnimeClient/UrlGenerator.php | 1 - tests/AnimeClient/DispatcherTest.php | 1 - tests/Ion/Type/ArrayTypeTest.php | 42 +++++++++++++------ 10 files changed, 36 insertions(+), 104 deletions(-) delete mode 100644 src/Aviat/AnimeClient/Controller/Stats.php delete mode 100644 src/Aviat/AnimeClient/Model/Stats.php delete mode 100644 src/Aviat/AnimeClient/Model/StatsChartsTrait.php diff --git a/src/Aviat/AnimeClient/Controller/Manga.php b/src/Aviat/AnimeClient/Controller/Manga.php index 620b9846..04195b52 100644 --- a/src/Aviat/AnimeClient/Controller/Manga.php +++ b/src/Aviat/AnimeClient/Controller/Manga.php @@ -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', diff --git a/src/Aviat/AnimeClient/Controller/Stats.php b/src/Aviat/AnimeClient/Controller/Stats.php deleted file mode 100644 index 2ebe84d0..00000000 --- a/src/Aviat/AnimeClient/Controller/Stats.php +++ /dev/null @@ -1,11 +0,0 @@ -menus as $name => $menu) diff --git a/src/Aviat/AnimeClient/Model.php b/src/Aviat/AnimeClient/Model.php index 71e201c0..165e979d 100644 --- a/src/Aviat/AnimeClient/Model.php +++ b/src/Aviat/AnimeClient/Model.php @@ -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."); diff --git a/src/Aviat/AnimeClient/Model/Manga.php b/src/Aviat/AnimeClient/Model/Manga.php index eb1f1566..d4b0bc44 100644 --- a/src/Aviat/AnimeClient/Model/Manga.php +++ b/src/Aviat/AnimeClient/Model/Manga.php @@ -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); diff --git a/src/Aviat/AnimeClient/Model/Stats.php b/src/Aviat/AnimeClient/Model/Stats.php deleted file mode 100644 index 653fffd8..00000000 --- a/src/Aviat/AnimeClient/Model/Stats.php +++ /dev/null @@ -1,30 +0,0 @@ -chartSetup(); - } - -} -// End of Stats.php \ No newline at end of file diff --git a/src/Aviat/AnimeClient/Model/StatsChartsTrait.php b/src/Aviat/AnimeClient/Model/StatsChartsTrait.php deleted file mode 100644 index 5f52404e..00000000 --- a/src/Aviat/AnimeClient/Model/StatsChartsTrait.php +++ /dev/null @@ -1,29 +0,0 @@ -pchart = new pChartFactory(); - } - -} -// End of StatsChartsTrait.php \ No newline at end of file diff --git a/src/Aviat/AnimeClient/UrlGenerator.php b/src/Aviat/AnimeClient/UrlGenerator.php index 972c1147..88a03cc1 100644 --- a/src/Aviat/AnimeClient/UrlGenerator.php +++ b/src/Aviat/AnimeClient/UrlGenerator.php @@ -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 diff --git a/tests/AnimeClient/DispatcherTest.php b/tests/AnimeClient/DispatcherTest.php index 432a35b9..480678a3 100644 --- a/tests/AnimeClient/DispatcherTest.php +++ b/tests/AnimeClient/DispatcherTest.php @@ -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' => [ diff --git a/tests/Ion/Type/ArrayTypeTest.php b/tests/Ion/Type/ArrayTypeTest.php index f5d97beb..b260ac28 100644 --- a/tests/Ion/Type/ArrayTypeTest.php +++ b/tests/Ion/Type/ArrayTypeTest.php @@ -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], @@ -40,7 +56,7 @@ class ArrayTypeTest extends AnimeClient_TestCase { 'method' => 'unique', 'array' => [1, 1, 3, 2, 2, 2, 3, 3, 5], 'args' => [SORT_REGULAR], - 'expected' => [0=>1, 2=>3, 3=>2, 8=>5] + 'expected' => [0 => 1, 2 => 3, 3 => 2, 8 => 5] ], 'array_values' => [ 'method' => 'values', @@ -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];