Skip to content

Commit

Permalink
Merge pull request #300 from gacela-project/refactor-config-resolver
Browse files Browse the repository at this point in the history
Remove ConfigNotFoundException
  • Loading branch information
Chemaclass authored Jul 24, 2023
2 parents 0904541 + 681e252 commit 9c2dfc4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 37 deletions.
13 changes: 4 additions & 9 deletions src/Console/Domain/AllAppModules/AppModuleCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Gacela\Console\Domain\AllAppModules;

use Gacela\Framework\ClassResolver\Config\ConfigNotFoundException;
use Gacela\Framework\ClassResolver\Config\ConfigResolver;
use Gacela\Framework\ClassResolver\DependencyProvider\DependencyProviderNotFoundException;
use Gacela\Framework\ClassResolver\DependencyProvider\DependencyProviderResolver;
Expand Down Expand Up @@ -78,17 +77,13 @@ private function findFactory(string $facadeClass): ?string
*/
private function findConfig(string $facadeClass): ?string
{
try {
$resolver = $this->configResolver->resolve($facadeClass);

if ((new ReflectionClass($resolver))->isAnonymous()) {
throw new ConfigNotFoundException($facadeClass);
}
$resolver = $this->configResolver->resolve($facadeClass);

return $resolver::class;
} catch (ConfigNotFoundException $e) {
if ((new ReflectionClass($resolver))->isAnonymous()) {
return null;
}

return $resolver::class;
}

/**
Expand Down
21 changes: 0 additions & 21 deletions src/Framework/ClassResolver/Config/ConfigNotFoundException.php

This file was deleted.

8 changes: 1 addition & 7 deletions src/Framework/ClassResolver/Config/ConfigResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,12 @@ final class ConfigResolver extends AbstractClassResolver

/**
* @param object|class-string $caller
*
* @throws ConfigNotFoundException
*/
public function resolve(object|string $caller): AbstractConfig
{
/** @var ?AbstractConfig $resolved */
/** @var AbstractConfig $resolved */
$resolved = $this->doResolve($caller);

if ($resolved === null) {
throw new ConfigNotFoundException($caller);
}

return $resolved;
}

Expand Down

0 comments on commit 9c2dfc4

Please sign in to comment.