From 60ef51dafde8ed5a80223672b66d980006bcec9c Mon Sep 17 00:00:00 2001 From: Nikola Posa Date: Sun, 26 Feb 2017 17:42:23 +0100 Subject: [PATCH] Improved Config loader naming. --- README.md | 4 ++-- .../{CachingLoader.php => CachingConfigLoader.php} | 8 +++++++- .../Loader/{FileLoader.php => FileConfigLoader.php} | 2 +- .../{StaticLoader.php => StaticConfigLoader.php} | 2 +- tests/Bootstrap/BootstrapTest.php | 10 +++++----- .../{FileLoaderTest.php => FileConfigLoaderTest.php} | 8 ++++---- 6 files changed, 20 insertions(+), 14 deletions(-) rename src/Config/Loader/{CachingLoader.php => CachingConfigLoader.php} (63%) rename src/Config/Loader/{FileLoader.php => FileConfigLoader.php} (94%) rename src/Config/Loader/{StaticLoader.php => StaticConfigLoader.php} (90%) rename tests/Config/Loader/{FileLoaderTest.php => FileConfigLoaderTest.php} (78%) diff --git a/README.md b/README.md index 18c7f1d..d18dbdd 100644 --- a/README.md +++ b/README.md @@ -59,11 +59,11 @@ Component that connects these different pieces together is `Bootstrap` which is ```php use Phoundation\Bootstrap\Bootstrap; -use Phoundation\Config\Loader\FileLoader; +use Phoundation\Config\Loader\FileConfigLoader; use Phoundation\Di\Container\Factory\ZendServiceManagerFactory; $bootstrap = new Bootstrap( - new FileLoader(glob(sprintf('config/{{,*.}global,{,*.}%s}.php', getenv('APP_ENV') ?: 'local'), GLOB_BRACE)), + new FileConfigLoader(glob(sprintf('config/{{,*.}global,{,*.}%s}.php', getenv('APP_ENV') ?: 'local'), GLOB_BRACE)), new ZendServiceManagerFactory() ); $diContainer = $bootstrap(); diff --git a/src/Config/Loader/CachingLoader.php b/src/Config/Loader/CachingConfigLoader.php similarity index 63% rename from src/Config/Loader/CachingLoader.php rename to src/Config/Loader/CachingConfigLoader.php index f1824d8..4243880 100644 --- a/src/Config/Loader/CachingLoader.php +++ b/src/Config/Loader/CachingConfigLoader.php @@ -12,9 +12,15 @@ namespace Phoundation\Config\Loader; +use Phoundation\Config\Config; + /** * @author Nikola Posa */ -class CachingLoader +final class CachingConfigLoader implements ConfigLoaderInterface { + public function __invoke() : Config + { + // TODO: Implement __invoke() method. + } } diff --git a/src/Config/Loader/FileLoader.php b/src/Config/Loader/FileConfigLoader.php similarity index 94% rename from src/Config/Loader/FileLoader.php rename to src/Config/Loader/FileConfigLoader.php index 464a426..34f838d 100644 --- a/src/Config/Loader/FileLoader.php +++ b/src/Config/Loader/FileConfigLoader.php @@ -17,7 +17,7 @@ /** * @author Nikola Posa */ -final class FileLoader extends AbstractLoader +final class FileConfigLoader extends AbstractLoader { /** * @var array diff --git a/src/Config/Loader/StaticLoader.php b/src/Config/Loader/StaticConfigLoader.php similarity index 90% rename from src/Config/Loader/StaticLoader.php rename to src/Config/Loader/StaticConfigLoader.php index a823976..1075916 100644 --- a/src/Config/Loader/StaticLoader.php +++ b/src/Config/Loader/StaticConfigLoader.php @@ -17,7 +17,7 @@ /** * @author Nikola Posa */ -final class StaticLoader implements ConfigLoaderInterface +final class StaticConfigLoader implements ConfigLoaderInterface { /** * @var array diff --git a/tests/Bootstrap/BootstrapTest.php b/tests/Bootstrap/BootstrapTest.php index f0ff9a3..f1beb89 100644 --- a/tests/Bootstrap/BootstrapTest.php +++ b/tests/Bootstrap/BootstrapTest.php @@ -14,7 +14,7 @@ use PHPUnit\Framework\TestCase; use Phoundation\Bootstrap\Bootstrap; -use Phoundation\Config\Loader\StaticLoader; +use Phoundation\Config\Loader\StaticConfigLoader; use Interop\Container\ContainerInterface; use Phoundation\Config\Config; use Phoundation\Di\Container\Factory\DiContainerFactoryInterface; @@ -35,7 +35,7 @@ class BootstrapTest extends TestCase public function it_produces_di_container() { $bootstrap = new Bootstrap( - new StaticLoader([ + new StaticConfigLoader([ 'foo' => 'bar', ]), new ZendServiceManagerFactory() @@ -53,7 +53,7 @@ public function it_produces_di_container() public function it_puts_config_into_di_container() { $bootstrap = new Bootstrap( - new StaticLoader([ + new StaticConfigLoader([ 'foo' => 'bar', ]), new ZendServiceManagerFactory() @@ -74,7 +74,7 @@ public function it_sets_php_settings_if_provided_through_config() $currentTz = ini_get('date.timezone'); $bootstrap = new Bootstrap( - new StaticLoader([ + new StaticConfigLoader([ 'php_settings' => [ 'date.timezone' => 'Europe/Belgrade', ], @@ -95,7 +95,7 @@ public function it_sets_php_settings_if_provided_through_config() public function it_registers_error_handler_if_provided_through_di_config() { $bootstrap = new Bootstrap( - new StaticLoader([ + new StaticConfigLoader([ 'di' => [ 'factories' => [ RunnerInterface::class => function () { diff --git a/tests/Config/Loader/FileLoaderTest.php b/tests/Config/Loader/FileConfigLoaderTest.php similarity index 78% rename from tests/Config/Loader/FileLoaderTest.php rename to tests/Config/Loader/FileConfigLoaderTest.php index 4290f70..459a5b3 100644 --- a/tests/Config/Loader/FileLoaderTest.php +++ b/tests/Config/Loader/FileConfigLoaderTest.php @@ -13,20 +13,20 @@ namespace Phoundation\Tests\Config; use PHPUnit\Framework\TestCase; -use Phoundation\Config\Loader\FileLoader; +use Phoundation\Config\Loader\FileConfigLoader; use Phoundation\Config\Config; /** * @author Nikola Posa */ -class FileLoaderTest extends TestCase +class FileConfigLoaderTest extends TestCase { /** * @test */ public function it_loads_config_from_path() { - $loader = new FileLoader([ + $loader = new FileConfigLoader([ __DIR__ . '/../../TestAsset/Config/global.php', ]); @@ -41,7 +41,7 @@ public function it_loads_config_from_path() */ public function it_loads_config_from_glob_path() { - $loader = new FileLoader(glob(__DIR__ . '/../../TestAsset/Config/{{,*.}global,{,*.}local}.php', GLOB_BRACE)); + $loader = new FileConfigLoader(glob(__DIR__ . '/../../TestAsset/Config/{{,*.}global,{,*.}local}.php', GLOB_BRACE)); $config = $loader();