Skip to content

Commit fe76ce1

Browse files
committed
feat(resolver): change enum to singular
1 parent 3517c59 commit fe76ce1

File tree

5 files changed

+21
-21
lines changed

5 files changed

+21
-21
lines changed

src/DependencyInjection/ContainerBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use ReflectionException;
1313
use RuntimeException;
1414
use Shared\Infrastructure\Resolver\Resolver;
15-
use Shared\Infrastructure\Resolver\Types;
15+
use Shared\Infrastructure\Resolver\Type;
1616
use Shared\Infrastructure\Settings\InMemorySettings;
1717
use Shared\Infrastructure\Settings\SettingsInterface;
1818
use function DI\autowire;
@@ -99,7 +99,7 @@ public function findDefinitions(array $ids): array
9999
*
100100
* @throws ReflectionException
101101
*/
102-
public function findClassesByResolver(string $class, Types $type, string $path): array
102+
public function findClassesByResolver(string $class, Type $type, string $path): array
103103
{
104104
return $this->resolver->resolve(
105105
$class,

src/Resolver/Resolver.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ public function __construct() {}
1818
* @throws ReflectionException
1919
*/
2020
public function resolve(
21-
string $toResolve,
22-
Types $type,
23-
string $directory = '',
24-
string $rootNamespace = null,
25-
string $rootPath = null,
21+
string $toResolve,
22+
Type $type,
23+
string $directory = '',
24+
string $rootNamespace = null,
25+
string $rootPath = null,
2626
?string $pathCacheFile = null,
2727
): array {
2828
if ($pathCacheFile) {
@@ -45,9 +45,9 @@ public function resolve(
4545
* @throws ReflectionException
4646
*/
4747
private function searchForClasses(
48-
string $toResolve,
49-
Types $type,
50-
string $directory,
48+
string $toResolve,
49+
Type $type,
50+
string $directory,
5151
?string $rootNamespace = '\\',
5252
?string $rootPath = null,
5353
): array {
@@ -69,13 +69,13 @@ private function searchForClasses(
6969
}
7070

7171
$interfaceNames = $reflectionClass->getInterfaceNames();
72-
$notImplementInterface = $type === Types::INTERFACE && !in_array($toResolve, $interfaceNames, true);
72+
$notImplementInterface = $type === Type::INTERFACE && !in_array($toResolve, $interfaceNames, true);
7373

7474
if ($notImplementInterface) {
7575
continue;
7676
}
7777

78-
$hasAttribute = $type === Types::ATTRIBUTE && !$reflectionClass->getAttributes($toResolve);
78+
$hasAttribute = $type === Type::ATTRIBUTE && !$reflectionClass->getAttributes($toResolve);
7979

8080
if ($hasAttribute) {
8181
continue;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Shared\Infrastructure\Resolver;
66

7-
enum Types: string
7+
enum Type: string
88
{
99
case INTERFACE = 'interface';
1010
case ATTRIBUTE = 'attribute';

tests/Units/DependencyInjection/ContainerBuilderTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use RuntimeException;
1212
use Shared\Infrastructure\DependencyInjection\CompilerPass;
1313
use Shared\Infrastructure\DependencyInjection\ContainerBuilder;
14-
use Shared\Infrastructure\Resolver\Types;
14+
use Shared\Infrastructure\Resolver\Type;
1515
use Tests\Shared\Infrastructure\Units\__resources__\Resolver\Interfaces\Example;
1616
use Tests\Shared\Infrastructure\Units\__resources__\Resolver\Interfaces\ExampleInterface;
1717
use Tests\Shared\Infrastructure\Utils\TestCase;
@@ -51,7 +51,7 @@ public function it_should_build_container_with_resolved_classes(): void
5151
{
5252
$classes = $this->containerBuilder->findClassesByResolver(
5353
ExampleInterface::class,
54-
Types::INTERFACE,
54+
Type::INTERFACE,
5555
'tests',
5656
);
5757

@@ -119,7 +119,7 @@ public function process(ContainerBuilder $containerBuilder): void
119119
{
120120
$classes = $containerBuilder->findClassesByResolver(
121121
ExampleInterface::class,
122-
Types::INTERFACE,
122+
Type::INTERFACE,
123123
'tests',
124124
);
125125

tests/Units/Resolver/ResolverTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use PHPUnit\Framework\TestCase;
66
use ReflectionException;
77
use Shared\Infrastructure\Resolver\Resolver;
8-
use Shared\Infrastructure\Resolver\Types;
8+
use Shared\Infrastructure\Resolver\Type;
99
use Tests\Shared\Infrastructure\Units\__resources__\Resolver\Attributes\ExampleAttribute;
1010
use Tests\Shared\Infrastructure\Units\__resources__\Resolver\Attributes\Example as ExampleWithAttribute;
1111
use Tests\Shared\Infrastructure\Units\__resources__\Resolver\Interfaces\Example;
@@ -55,7 +55,7 @@ public function it_should_can_resolve_interfaces(): void
5555

5656
$actual = $resolver->resolve(
5757
ExampleInterface::class,
58-
Types::INTERFACE,
58+
Type::INTERFACE,
5959
'tests',
6060
$this->rootNamespace,
6161
$this->rootPath
@@ -75,7 +75,7 @@ public function it_should_can_resolve_interfaces_cache(): void
7575

7676
$resolver->resolve(
7777
ExampleInterface::class,
78-
Types::INTERFACE,
78+
Type::INTERFACE,
7979
'tests',
8080
$this->rootNamespace,
8181
$this->rootPath,
@@ -84,7 +84,7 @@ public function it_should_can_resolve_interfaces_cache(): void
8484

8585
$actual = $resolver->resolve(
8686
ExampleInterface::class,
87-
Types::INTERFACE,
87+
Type::INTERFACE,
8888
'tests',
8989
$this->rootNamespace,
9090
$this->rootPath,
@@ -105,7 +105,7 @@ public function it_should_can_resolve_attributes(): void
105105

106106
$actual = $resolver->resolve(
107107
ExampleAttribute::class,
108-
Types::ATTRIBUTE,
108+
Type::ATTRIBUTE,
109109
'tests',
110110
$this->rootNamespace,
111111
$this->rootPath

0 commit comments

Comments
 (0)