From d0ae395bbb8d323cce2ae3633ab7a59df3025daf Mon Sep 17 00:00:00 2001
From: Bart Jaskulski <bjaskulski@protonmail.com>
Date: Sun, 10 Mar 2024 02:15:58 +0100
Subject: [PATCH] refactor: rename loader to definitions

Signed-off-by: Bart Jaskulski <bjaskulski@protonmail.com>
---
 src/Binding/Loader/ArrayBindingLoader.php    |  2 +-
 src/Binding/Loader/FilesystemDefinitions.php |  2 +-
 src/Extension/ConditionalExtension.php       |  4 ++--
 src/Extension/ConfigExtension.php            |  4 ++--
 src/Extension/LegacyExtension.php            |  1 -
 tests/Binding/ArrayBindingLoaderTest.php     | 10 +++++-----
 tests/Binding/CompositeBindingLoaderTest.php | 20 ++++++++++----------
 tests/Binding/DirectoryBasedLoaderTest.php   |  8 ++++----
 tests/HookDriver/GenericDriverTest.php       |  4 ++--
 9 files changed, 27 insertions(+), 28 deletions(-)

diff --git a/src/Binding/Loader/ArrayBindingLoader.php b/src/Binding/Loader/ArrayBindingLoader.php
index 4991d12..6eacee1 100644
--- a/src/Binding/Loader/ArrayBindingLoader.php
+++ b/src/Binding/Loader/ArrayBindingLoader.php
@@ -7,7 +7,7 @@ use WPDesk\Init\Binding\DefinitionFactory;
 use WPDesk\Init\Configuration\ReadableConfig;
 use WPDesk\Init\Plugin\Plugin;
 
-class ArrayBindingLoader implements BindingDefinitions {
+class ArrayDefinitions implements BindingDefinitions {
 
 	/** @var array */
 	private $bindings;
diff --git a/src/Binding/Loader/FilesystemDefinitions.php b/src/Binding/Loader/FilesystemDefinitions.php
index d46262d..504ff66 100644
--- a/src/Binding/Loader/FilesystemDefinitions.php
+++ b/src/Binding/Loader/FilesystemDefinitions.php
@@ -45,6 +45,6 @@ class FilesystemDefinitions implements BindingDefinitions {
 			$hooks = [ $filename->get_filename_without_extension() => $hooks ];
 		}
 
-		yield from (new ArrayBindingLoader( $hooks ) )->load();
+		yield from (new ArrayDefinitions( $hooks ) )->load();
 	}
 }
diff --git a/src/Extension/ConditionalExtension.php b/src/Extension/ConditionalExtension.php
index dcc5dc5..f77d8e0 100644
--- a/src/Extension/ConditionalExtension.php
+++ b/src/Extension/ConditionalExtension.php
@@ -11,7 +11,7 @@ use Monolog\Processor\PsrLogMessageProcessor;
 use Monolog\Processor\UidProcessor;
 use Psr\Container\ContainerInterface;
 use Psr\Log\LoggerInterface;
-use WPDesk\Init\Binding\Loader\ArrayBindingLoader;
+use WPDesk\Init\Binding\Loader\ArrayDefinitions;
 use WPDesk\Init\Binding\Loader\BindingDefinitions;
 use WPDesk\Init\Configuration\ReadableConfig;
 use WPDesk\Init\DependencyInjection\ContainerBuilder;
@@ -33,7 +33,7 @@ class ConditionalExtension implements Extension {
 			$bindings[] = WPDeskTrackerBridge::class;
 		}
 
-		return new ArrayBindingLoader( $bindings );
+		return new ArrayDefinitions( $bindings );
 	}
 
 	public function build( ContainerBuilder $builder, Plugin $plugin, ReadableConfig $config ): void {
diff --git a/src/Extension/ConfigExtension.php b/src/Extension/ConfigExtension.php
index 035d384..303c514 100644
--- a/src/Extension/ConfigExtension.php
+++ b/src/Extension/ConfigExtension.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
 namespace WPDesk\Init\Extension;
 
 use Psr\Container\ContainerInterface;
-use WPDesk\Init\Binding\Loader\ArrayBindingLoader;
+use WPDesk\Init\Binding\Loader\ArrayDefinitions;
 use WPDesk\Init\Binding\Loader\BindingDefinitions;
 use WPDesk\Init\Binding\Loader\FilesystemDefinitions;
 use WPDesk\Init\Configuration\Configuration;
@@ -24,7 +24,7 @@ class ConfigExtension implements Extension {
 			);
 		}
 
-		return new ArrayBindingLoader( [] );
+		return new ArrayDefinitions( [] );
 	}
 
 	public function build( ContainerBuilder $builder, Plugin $plugin, ReadableConfig $config ): void {
diff --git a/src/Extension/LegacyExtension.php b/src/Extension/LegacyExtension.php
index 4dd299a..b03a275 100644
--- a/src/Extension/LegacyExtension.php
+++ b/src/Extension/LegacyExtension.php
@@ -5,7 +5,6 @@ declare(strict_types=1);
 namespace WPDesk\Init\Extension;
 
 use Psr\Container\ContainerInterface;
-use WPDesk\Init\Binding\Loader\ArrayBindingLoader;
 use WPDesk\Init\Binding\Loader\BindingDefinitions;
 use WPDesk\Init\Configuration\ReadableConfig;
 use WPDesk\Init\DependencyInjection\ContainerBuilder;
diff --git a/tests/Binding/ArrayBindingLoaderTest.php b/tests/Binding/ArrayBindingLoaderTest.php
index 978d743..a7e5a20 100644
--- a/tests/Binding/ArrayBindingLoaderTest.php
+++ b/tests/Binding/ArrayBindingLoaderTest.php
@@ -3,18 +3,18 @@ declare( strict_types=1 );
 
 namespace WPDesk\Init\Tests\Binding;
 
-use WPDesk\Init\Binding\Loader\ArrayBindingLoader;
+use WPDesk\Init\Binding\Loader\ArrayDefinitions;
 use WPDesk\Init\Tests\TestCase;
 
 class ArrayBindingLoaderTest extends TestCase {
 
 	public function test_loading_empty_bindings(): void {
-		$a = new ArrayBindingLoader([]);
+		$a = new ArrayDefinitions([]);
 		$this->assertEquals(0, iterator_count($a->load()));
 	}
 
 	public function test_loading_structured_bindings(): void {
-		$a = new ArrayBindingLoader([
+		$a = new ArrayDefinitions([
 			'hook' => [
 				'bind1',
 				'bind2',
@@ -38,7 +38,7 @@ class ArrayBindingLoaderTest extends TestCase {
 	}
 
 	public function test_loading_unstructured_bindings(): void {
-		$a = new ArrayBindingLoader([
+		$a = new ArrayDefinitions([
 			'bind1',
 			'bind2',
 			'hook' => 'bind3',
@@ -51,7 +51,7 @@ class ArrayBindingLoaderTest extends TestCase {
 			iterator_to_array($a->load())
 		);
 
-		$a = new ArrayBindingLoader([
+		$a = new ArrayDefinitions([
 			'bind1',
 			'not_a_hook' => 'bind2',
 			'hook' => ['bind3'],
diff --git a/tests/Binding/CompositeBindingLoaderTest.php b/tests/Binding/CompositeBindingLoaderTest.php
index 0d8a755..9cfb118 100644
--- a/tests/Binding/CompositeBindingLoaderTest.php
+++ b/tests/Binding/CompositeBindingLoaderTest.php
@@ -3,20 +3,20 @@ declare( strict_types=1 );
 
 namespace WPDesk\Init\Tests\Binding;
 
-use WPDesk\Init\Binding\Loader\ArrayBindingLoader;
+use WPDesk\Init\Binding\Loader\ArrayDefinitions;
 use WPDesk\Init\Binding\Loader\CompositeBindingLoader;
 use WPDesk\Init\Tests\TestCase;
 
 class CompositeBindingLoaderTest extends TestCase {
 
 	public function test_loading_empty_bindings(): void {
-		$a = new CompositeBindingLoader(new ArrayBindingLoader([]));
+		$a = new CompositeBindingLoader(new ArrayDefinitions([]));
 		$this->assertEquals(0, iterator_count($a->load()));
 	}
 
 	public function test_loading_structured_bindings(): void {
 		$a = new CompositeBindingLoader(
-			new ArrayBindingLoader(
+			new ArrayDefinitions(
 				[
 					'hook' => [
 						'bind1',
@@ -24,7 +24,7 @@ class CompositeBindingLoaderTest extends TestCase {
 					],
 				]
 			),
-			new ArrayBindingLoader(
+			new ArrayDefinitions(
 				[
 					'hook2' => [
 						'bind3',
@@ -48,13 +48,13 @@ class CompositeBindingLoaderTest extends TestCase {
 
 	public function test_loading_unstructured_bindings(): void {
 		$a = new CompositeBindingLoader(
-			new ArrayBindingLoader(	[
+			new ArrayDefinitions(	[
 				'bind1',
 			]),
-			new ArrayBindingLoader([
+			new ArrayDefinitions([
 				'bind2',
 			]),
-			new ArrayBindingLoader([
+			new ArrayDefinitions([
 				'hook' => 'bind3',
 			])
 		);
@@ -71,13 +71,13 @@ class CompositeBindingLoaderTest extends TestCase {
 		);
 
 		$a = new CompositeBindingLoader(
-			new ArrayBindingLoader([
+			new ArrayDefinitions([
 				'bind1',
 			]),
-			new ArrayBindingLoader([
+			new ArrayDefinitions([
 			'not_a_hook' => 'bind2',
 			]),
-			new ArrayBindingLoader([
+			new ArrayDefinitions([
 			'hook' => ['bind3'],
 			]),
 		);
diff --git a/tests/Binding/DirectoryBasedLoaderTest.php b/tests/Binding/DirectoryBasedLoaderTest.php
index 9db2c1a..68cacc3 100644
--- a/tests/Binding/DirectoryBasedLoaderTest.php
+++ b/tests/Binding/DirectoryBasedLoaderTest.php
@@ -4,7 +4,7 @@ declare( strict_types=1 );
 namespace WPDesk\Init\Tests\Binding;
 
 use WPDesk\Init\Binding\Definition\UnknownDefinition;
-use WPDesk\Init\Binding\Loader\DirectoryBasedLoader;
+use WPDesk\Init\Binding\Loader\FilesystemDefinitions;
 use WPDesk\Init\Configuration\Configuration;
 use WPDesk\Init\Tests\TestCase;
 
@@ -12,13 +12,13 @@ class DirectoryBasedLoaderTest extends TestCase {
 
 	public function xtest_throws_when_configuration_entry_is_missing(): void {
 		$this->expectException(\InvalidArgumentException::class);
-		$a = new DirectoryBasedLoader(new Configuration([]));
+		$a = new FilesystemDefinitions(new Configuration([]));
 		$a->load();
 	}
 
 	public function test_loading_empty_bindings(): void {
 		$this->initTempPlugin('hook-bindings');
-		$a = new DirectoryBasedLoader('./');
+		$a = new FilesystemDefinitions('./');
 		$actual = iterator_to_array($a->load(), false);
 		$this->assertEquals(
 			[
@@ -32,7 +32,7 @@ class DirectoryBasedLoaderTest extends TestCase {
 
 	public function test_load_illogical_bindings(): void {
 		$this->initTempPlugin('borked-bindings');
-		$a = new DirectoryBasedLoader('./');
+		$a = new FilesystemDefinitions('./');
 
 		$actual = iterator_to_array($a->load(), false);
 		$this->assertEquals(
diff --git a/tests/HookDriver/GenericDriverTest.php b/tests/HookDriver/GenericDriverTest.php
index e524998..991b0e1 100644
--- a/tests/HookDriver/GenericDriverTest.php
+++ b/tests/HookDriver/GenericDriverTest.php
@@ -8,7 +8,7 @@ use WPDesk\Init\Binding\ObservableBinder;
 use WPDesk\Init\HookDriver\GenericDriver;
 use WPDesk\Init\Configuration\Configuration;
 use Psr\Container\ContainerInterface;
-use WPDesk\Init\Binding\Loader\ArrayBindingLoader;
+use WPDesk\Init\Binding\Loader\ArrayDefinitions;
 use WPDesk\Init\Binding\StoppableBinder;
 use WPDesk\Init\Tests\TestCase;
 
@@ -59,7 +59,7 @@ class GenericDriverTest extends TestCase {
 
 	/** @dataProvider provider */
 	public function test_register_hooks( array $hook_bindings, callable $assertion ): void {
-		$driver = new GenericDriver( new ArrayBindingLoader(array_keys($hook_bindings)) );
+		$driver = new GenericDriver( new ArrayDefinitions(array_keys($hook_bindings)) );
 		$driver->register_hooks( new Configuration([]), $this->getContainer($hook_bindings) );
 
 
-- 
GitLab