Skip to content

Commit

Permalink
Merge pull request #170 from gacela-project/feature/refactor-setup-ga…
Browse files Browse the repository at this point in the history
…cela

Refactor SetupGacela
  • Loading branch information
Chemaclass committed Jun 16, 2022
2 parents 528ba03 + 6856c94 commit 09d2312
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
12 changes: 6 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 19 additions & 9 deletions src/Framework/Bootstrap/SetupGacela.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@

final class SetupGacela extends AbstractSetupGacela
{
/** @var ?callable(ConfigBuilder):void */
private $configFn = null;
/** @var callable(ConfigBuilder):void */
private $configFn;

/** @var ?callable(MappingInterfacesBuilder,array<string,mixed>):void */
private $mappingInterfacesFn = null;
/** @var callable(MappingInterfacesBuilder,array<string,mixed>):void */
private $mappingInterfacesFn;

/** @var ?callable(SuffixTypesBuilder):void */
private $suffixTypesFn = null;
/** @var callable(SuffixTypesBuilder):void */
private $suffixTypesFn;

/** @var array<string,class-string|object|callable> */
private array $externalServices = [];
Expand All @@ -31,6 +31,16 @@ final class SetupGacela extends AbstractSetupGacela

private bool $cacheEnabled = true;

public function __construct()
{
$this->configFn = static function (): void {
};
$this->mappingInterfacesFn = static function (): void {
};
$this->suffixTypesFn = static function (): void {
};
}

/**
* @param Closure(GacelaConfig):void $setupGacelaFileFn
*/
Expand Down Expand Up @@ -91,7 +101,7 @@ public function buildConfig(ConfigBuilder $configBuilder): ConfigBuilder
$configBuilder = $this->configBuilder;
}

$this->configFn && ($this->configFn)($configBuilder);
($this->configFn)($configBuilder);

return $configBuilder;
}
Expand Down Expand Up @@ -119,7 +129,7 @@ public function buildMappingInterfaces(
$mappingInterfacesBuilder = $this->mappingInterfacesBuilder;
}

$this->mappingInterfacesFn && ($this->mappingInterfacesFn)(
($this->mappingInterfacesFn)(
$mappingInterfacesBuilder,
array_merge($this->externalServices, $externalServices)
);
Expand All @@ -146,7 +156,7 @@ public function buildSuffixTypes(SuffixTypesBuilder $suffixTypesBuilder): Suffix
$suffixTypesBuilder = $this->suffixTypesBuilder;
}

$this->suffixTypesFn && ($this->suffixTypesFn)($suffixTypesBuilder);
($this->suffixTypesFn)($suffixTypesBuilder);

return $suffixTypesBuilder;
}
Expand Down

0 comments on commit 09d2312

Please sign in to comment.