From bf01e41e327be8dd4f786c01ff89b513f31d5c6c Mon Sep 17 00:00:00 2001
From: "Timothy J. Warren" <tim@timshomepage.net>
Date: Mon, 29 Aug 2016 16:36:13 -0400
Subject: [PATCH] Move src files to root of src/

---
 composer.json                                 |  4 ++--
 index.php                                     | 21 +------------------
 src/{Aviat/AnimeClient => }/AnimeClient.php   |  2 +-
 .../AnimeClient => }/Auth/HummingbirdAuth.php |  0
 .../AnimeClient => }/Command/BaseCommand.php  |  2 +-
 .../AnimeClient => }/Command/CacheImages.php  |  0
 .../AnimeClient => }/Command/ClearCache.php   |  0
 src/{Aviat/AnimeClient => }/Controller.php    |  0
 .../AnimeClient => }/Controller/Anime.php     |  0
 .../Controller/Collection.php                 |  0
 .../AnimeClient => }/Controller/Manga.php     |  0
 src/{Aviat/AnimeClient => }/Dispatcher.php    |  8 +++----
 src/{Aviat/AnimeClient => }/Helper/Menu.php   |  0
 .../Hummingbird/Enum/AnimeAiringStatus.php    |  0
 .../Hummingbird/Enum/AnimeShowType.php        |  0
 .../Hummingbird/Enum/AnimeWatchingStatus.php  |  0
 .../Hummingbird/Enum/MangaReadingStatus.php   |  0
 .../Transformer/AnimeListTransformer.php      |  0
 .../Transformer/MangaListTransformer.php      |  0
 .../Transformer/MangaListsZipper.php          |  0
 src/{Aviat/AnimeClient => }/MenuGenerator.php |  0
 src/{Aviat/AnimeClient => }/Model/API.php     |  0
 src/{Aviat/AnimeClient => }/Model/Anime.php   |  0
 .../Model/AnimeCollection.php                 |  0
 .../AnimeClient => }/Model/Collection.php     |  0
 src/{Aviat/AnimeClient => }/Model/DB.php      |  0
 src/{Aviat/AnimeClient => }/Model/Manga.php   |  0
 src/{Aviat/AnimeClient => }/RoutingBase.php   |  0
 src/{Aviat/AnimeClient => }/UrlGenerator.php  |  0
 src/{Aviat/AnimeClient => }/Util.php          |  0
 tests/bootstrap.php                           | 19 -----------------
 31 files changed, 8 insertions(+), 48 deletions(-)
 rename src/{Aviat/AnimeClient => }/AnimeClient.php (96%)
 rename src/{Aviat/AnimeClient => }/Auth/HummingbirdAuth.php (100%)
 rename src/{Aviat/AnimeClient => }/Command/BaseCommand.php (97%)
 rename src/{Aviat/AnimeClient => }/Command/CacheImages.php (100%)
 rename src/{Aviat/AnimeClient => }/Command/ClearCache.php (100%)
 rename src/{Aviat/AnimeClient => }/Controller.php (100%)
 rename src/{Aviat/AnimeClient => }/Controller/Anime.php (100%)
 rename src/{Aviat/AnimeClient => }/Controller/Collection.php (100%)
 rename src/{Aviat/AnimeClient => }/Controller/Manga.php (100%)
 rename src/{Aviat/AnimeClient => }/Dispatcher.php (98%)
 rename src/{Aviat/AnimeClient => }/Helper/Menu.php (100%)
 rename src/{Aviat/AnimeClient => }/Hummingbird/Enum/AnimeAiringStatus.php (100%)
 rename src/{Aviat/AnimeClient => }/Hummingbird/Enum/AnimeShowType.php (100%)
 rename src/{Aviat/AnimeClient => }/Hummingbird/Enum/AnimeWatchingStatus.php (100%)
 rename src/{Aviat/AnimeClient => }/Hummingbird/Enum/MangaReadingStatus.php (100%)
 rename src/{Aviat/AnimeClient => }/Hummingbird/Transformer/AnimeListTransformer.php (100%)
 rename src/{Aviat/AnimeClient => }/Hummingbird/Transformer/MangaListTransformer.php (100%)
 rename src/{Aviat/AnimeClient => }/Hummingbird/Transformer/MangaListsZipper.php (100%)
 rename src/{Aviat/AnimeClient => }/MenuGenerator.php (100%)
 rename src/{Aviat/AnimeClient => }/Model/API.php (100%)
 rename src/{Aviat/AnimeClient => }/Model/Anime.php (100%)
 rename src/{Aviat/AnimeClient => }/Model/AnimeCollection.php (100%)
 rename src/{Aviat/AnimeClient => }/Model/Collection.php (100%)
 rename src/{Aviat/AnimeClient => }/Model/DB.php (100%)
 rename src/{Aviat/AnimeClient => }/Model/Manga.php (100%)
 rename src/{Aviat/AnimeClient => }/RoutingBase.php (100%)
 rename src/{Aviat/AnimeClient => }/UrlGenerator.php (100%)
 rename src/{Aviat/AnimeClient => }/Util.php (100%)

diff --git a/composer.json b/composer.json
index c2198852..64c450ea 100644
--- a/composer.json
+++ b/composer.json
@@ -4,12 +4,12 @@
 	"license":"MIT",
 	"autoload": {
 		"psr-4": {
-			"Aviat\\Ion\\": "src/"
+			"Aviat\\AnimeClient\\": "src/"
 		}
 	},
 	"autoload-dev": {
 		"psr-4": {
-			"Aviat\\Ion\\Tests\\": "tests/",
+			"Aviat\\AnimeClient\\Tests\\": "tests/",
 			"CodeIgniter\\": "build/CodeIgniter/"
 		}
 	},
diff --git a/index.php b/index.php
index 571f1987..edab666c 100644
--- a/index.php
+++ b/index.php
@@ -34,27 +34,9 @@ function _dir()
 
 // Define base directories
 $APP_DIR = _dir(__DIR__, 'app');
-$SRC_DIR = _dir(__DIR__, 'src');
 $CONF_DIR = _dir($APP_DIR, 'config');
 
-/**
- * Set up autoloaders
- *
- * @codeCoverageIgnore
- * @return void
- */
-spl_autoload_register(function($class) use ($SRC_DIR) {
-	$class_parts = explode('\\', $class);
-	$ns_path = $SRC_DIR . '/' . implode('/', $class_parts) . ".php";
-
-	if (file_exists($ns_path))
-	{
-		require_once($ns_path);
-		return;
-	}
-});
-
-// Set up autoloader for third-party dependencies
+// Load composer autoloader
 require _dir(__DIR__, '/vendor/autoload.php');
 
 // -------------------------------------------------------------------------
@@ -86,7 +68,6 @@ $container = $di($config_array);
 
 // Unset 'constants'
 unset($APP_DIR);
-unset($SRC_DIR);
 unset($CONF_DIR);
 
 // -----------------------------------------------------------------------------
diff --git a/src/Aviat/AnimeClient/AnimeClient.php b/src/AnimeClient.php
similarity index 96%
rename from src/Aviat/AnimeClient/AnimeClient.php
rename to src/AnimeClient.php
index f737124d..390c6a3e 100644
--- a/src/Aviat/AnimeClient/AnimeClient.php
+++ b/src/AnimeClient.php
@@ -15,7 +15,7 @@ namespace Aviat\AnimeClient;
 
 use Yosymfony\Toml\Toml;
 
-define('SRC_DIR', realpath(__DIR__ . '/../../'));
+define('SRC_DIR', realpath(__DIR__));
 
 /**
  * Application constants
diff --git a/src/Aviat/AnimeClient/Auth/HummingbirdAuth.php b/src/Auth/HummingbirdAuth.php
similarity index 100%
rename from src/Aviat/AnimeClient/Auth/HummingbirdAuth.php
rename to src/Auth/HummingbirdAuth.php
diff --git a/src/Aviat/AnimeClient/Command/BaseCommand.php b/src/Command/BaseCommand.php
similarity index 97%
rename from src/Aviat/AnimeClient/Command/BaseCommand.php
rename to src/Command/BaseCommand.php
index 923df39a..800ff51e 100644
--- a/src/Aviat/AnimeClient/Command/BaseCommand.php
+++ b/src/Command/BaseCommand.php
@@ -53,7 +53,7 @@ class BaseCommand extends Command {
 	 */
 	protected function setupContainer()
 	{
-		$CONF_DIR = realpath(__DIR__ . '/../../../../app/config/');
+		$CONF_DIR = realpath(__DIR__ . '/../../app/config/');
 		require_once $CONF_DIR . '/base_config.php'; // $base_config
 
 		$config = AnimeClient::load_toml($CONF_DIR);
diff --git a/src/Aviat/AnimeClient/Command/CacheImages.php b/src/Command/CacheImages.php
similarity index 100%
rename from src/Aviat/AnimeClient/Command/CacheImages.php
rename to src/Command/CacheImages.php
diff --git a/src/Aviat/AnimeClient/Command/ClearCache.php b/src/Command/ClearCache.php
similarity index 100%
rename from src/Aviat/AnimeClient/Command/ClearCache.php
rename to src/Command/ClearCache.php
diff --git a/src/Aviat/AnimeClient/Controller.php b/src/Controller.php
similarity index 100%
rename from src/Aviat/AnimeClient/Controller.php
rename to src/Controller.php
diff --git a/src/Aviat/AnimeClient/Controller/Anime.php b/src/Controller/Anime.php
similarity index 100%
rename from src/Aviat/AnimeClient/Controller/Anime.php
rename to src/Controller/Anime.php
diff --git a/src/Aviat/AnimeClient/Controller/Collection.php b/src/Controller/Collection.php
similarity index 100%
rename from src/Aviat/AnimeClient/Controller/Collection.php
rename to src/Controller/Collection.php
diff --git a/src/Aviat/AnimeClient/Controller/Manga.php b/src/Controller/Manga.php
similarity index 100%
rename from src/Aviat/AnimeClient/Controller/Manga.php
rename to src/Controller/Manga.php
diff --git a/src/Aviat/AnimeClient/Dispatcher.php b/src/Dispatcher.php
similarity index 98%
rename from src/Aviat/AnimeClient/Dispatcher.php
rename to src/Dispatcher.php
index 1d57e3c9..6f79959c 100644
--- a/src/Aviat/AnimeClient/Dispatcher.php
+++ b/src/Dispatcher.php
@@ -12,9 +12,6 @@
  */
 namespace Aviat\AnimeClient;
 
-use Aura\Web\Request;
-use Aura\Web\Response;
-
 use Aviat\Ion\Di\ContainerInterface;
 use Aviat\Ion\Friend;
 
@@ -38,7 +35,7 @@ class Dispatcher extends RoutingBase {
 
 	/**
 	 * Class wrapper for input superglobals
-	 * @var object
+	 * @var Psr\Http\Message\ServerRequestInterface
 	 */
 	protected $request;
 
@@ -215,6 +212,7 @@ class Dispatcher extends RoutingBase {
 	{
 		$default_namespace = AnimeClient::DEFAULT_CONTROLLER_NAMESPACE;
 		$path = str_replace('\\', '/', $default_namespace);
+		$path = str_replace('Aviat/AnimeClient/', '', $path);
 		$path = trim($path, '/');
 		$actual_path = realpath(\_dir(AnimeClient::SRC_DIR, $path));
 		$class_files = glob("{$actual_path}/*.php");
@@ -273,7 +271,7 @@ class Dispatcher extends RoutingBase {
 		$params = [];
 
 		switch($failure->failedRule) {
-			case 'Aura\Router\Rule\Alows':
+			case 'Aura\Router\Rule\Allows':
 				$params = [
 					'http_code' => 405,
 					'title' => '405 Method Not Allowed',
diff --git a/src/Aviat/AnimeClient/Helper/Menu.php b/src/Helper/Menu.php
similarity index 100%
rename from src/Aviat/AnimeClient/Helper/Menu.php
rename to src/Helper/Menu.php
diff --git a/src/Aviat/AnimeClient/Hummingbird/Enum/AnimeAiringStatus.php b/src/Hummingbird/Enum/AnimeAiringStatus.php
similarity index 100%
rename from src/Aviat/AnimeClient/Hummingbird/Enum/AnimeAiringStatus.php
rename to src/Hummingbird/Enum/AnimeAiringStatus.php
diff --git a/src/Aviat/AnimeClient/Hummingbird/Enum/AnimeShowType.php b/src/Hummingbird/Enum/AnimeShowType.php
similarity index 100%
rename from src/Aviat/AnimeClient/Hummingbird/Enum/AnimeShowType.php
rename to src/Hummingbird/Enum/AnimeShowType.php
diff --git a/src/Aviat/AnimeClient/Hummingbird/Enum/AnimeWatchingStatus.php b/src/Hummingbird/Enum/AnimeWatchingStatus.php
similarity index 100%
rename from src/Aviat/AnimeClient/Hummingbird/Enum/AnimeWatchingStatus.php
rename to src/Hummingbird/Enum/AnimeWatchingStatus.php
diff --git a/src/Aviat/AnimeClient/Hummingbird/Enum/MangaReadingStatus.php b/src/Hummingbird/Enum/MangaReadingStatus.php
similarity index 100%
rename from src/Aviat/AnimeClient/Hummingbird/Enum/MangaReadingStatus.php
rename to src/Hummingbird/Enum/MangaReadingStatus.php
diff --git a/src/Aviat/AnimeClient/Hummingbird/Transformer/AnimeListTransformer.php b/src/Hummingbird/Transformer/AnimeListTransformer.php
similarity index 100%
rename from src/Aviat/AnimeClient/Hummingbird/Transformer/AnimeListTransformer.php
rename to src/Hummingbird/Transformer/AnimeListTransformer.php
diff --git a/src/Aviat/AnimeClient/Hummingbird/Transformer/MangaListTransformer.php b/src/Hummingbird/Transformer/MangaListTransformer.php
similarity index 100%
rename from src/Aviat/AnimeClient/Hummingbird/Transformer/MangaListTransformer.php
rename to src/Hummingbird/Transformer/MangaListTransformer.php
diff --git a/src/Aviat/AnimeClient/Hummingbird/Transformer/MangaListsZipper.php b/src/Hummingbird/Transformer/MangaListsZipper.php
similarity index 100%
rename from src/Aviat/AnimeClient/Hummingbird/Transformer/MangaListsZipper.php
rename to src/Hummingbird/Transformer/MangaListsZipper.php
diff --git a/src/Aviat/AnimeClient/MenuGenerator.php b/src/MenuGenerator.php
similarity index 100%
rename from src/Aviat/AnimeClient/MenuGenerator.php
rename to src/MenuGenerator.php
diff --git a/src/Aviat/AnimeClient/Model/API.php b/src/Model/API.php
similarity index 100%
rename from src/Aviat/AnimeClient/Model/API.php
rename to src/Model/API.php
diff --git a/src/Aviat/AnimeClient/Model/Anime.php b/src/Model/Anime.php
similarity index 100%
rename from src/Aviat/AnimeClient/Model/Anime.php
rename to src/Model/Anime.php
diff --git a/src/Aviat/AnimeClient/Model/AnimeCollection.php b/src/Model/AnimeCollection.php
similarity index 100%
rename from src/Aviat/AnimeClient/Model/AnimeCollection.php
rename to src/Model/AnimeCollection.php
diff --git a/src/Aviat/AnimeClient/Model/Collection.php b/src/Model/Collection.php
similarity index 100%
rename from src/Aviat/AnimeClient/Model/Collection.php
rename to src/Model/Collection.php
diff --git a/src/Aviat/AnimeClient/Model/DB.php b/src/Model/DB.php
similarity index 100%
rename from src/Aviat/AnimeClient/Model/DB.php
rename to src/Model/DB.php
diff --git a/src/Aviat/AnimeClient/Model/Manga.php b/src/Model/Manga.php
similarity index 100%
rename from src/Aviat/AnimeClient/Model/Manga.php
rename to src/Model/Manga.php
diff --git a/src/Aviat/AnimeClient/RoutingBase.php b/src/RoutingBase.php
similarity index 100%
rename from src/Aviat/AnimeClient/RoutingBase.php
rename to src/RoutingBase.php
diff --git a/src/Aviat/AnimeClient/UrlGenerator.php b/src/UrlGenerator.php
similarity index 100%
rename from src/Aviat/AnimeClient/UrlGenerator.php
rename to src/UrlGenerator.php
diff --git a/src/Aviat/AnimeClient/Util.php b/src/Util.php
similarity index 100%
rename from src/Aviat/AnimeClient/Util.php
rename to src/Util.php
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 27f1c52e..95115763 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -31,27 +31,8 @@ function _dir()
 // -----------------------------------------------------------------------------
 
 require _dir(__DIR__, 'AnimeClient_TestCase.php');
-
-// Define base path constants
 require _dir(__DIR__, '../vendor/autoload.php');
 
-/**
- * Set up autoloaders
- *
- * @codeCoverageIgnore
- * @return void
- */
-spl_autoload_register(function ($class) {
-	$class_parts = explode('\\', $class);
-	$ns_path = realpath(__DIR__ . '/../src') . '/' . implode('/', $class_parts) . ".php";
-
-	if (file_exists($ns_path))
-	{
-		require_once($ns_path);
-		return;
-	}
-});
-
 // -----------------------------------------------------------------------------
 // Ini Settings
 // -----------------------------------------------------------------------------