Skip to content

Commit

Permalink
Allow optional project namespace on class name finder rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Chemaclass committed Oct 12, 2022
1 parent 14d2339 commit 5c3cfb5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

- Read autoload-dev psr-4 namespaces for gacela make commands.
- Cache default resolved gacela class.
- Allow optional project namespace on class name finder rules.

### 0.26.0
#### 2022-10-01
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,17 @@ final class FinderRuleWithModulePrefix implements FinderRuleInterface
{
public function buildClassCandidate(string $projectNamespace, string $resolvableType, ClassInfo $classInfo): string
{
if ($projectNamespace !== '') {
return sprintf(
'\\%s\\%s\\%s',
trim($projectNamespace, '\\'),
$classInfo->getModuleName(),
$classInfo->getModuleName() . $resolvableType
);
}

return sprintf(
'\\%s\\%s\\%s',
trim($projectNamespace, '\\'),
'\\%s\\%s',
$classInfo->getModuleName(),
$classInfo->getModuleName() . $resolvableType
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,17 @@ final class FinderRuleWithoutModulePrefix implements FinderRuleInterface
{
public function buildClassCandidate(string $projectNamespace, string $resolvableType, ClassInfo $classInfo): string
{
if ($projectNamespace !== '') {
return sprintf(
'\\%s\\%s\\%s',
trim($projectNamespace, '\\'),
$classInfo->getModuleName(),
$resolvableType
);
}

return sprintf(
'\\%s\\%s\\%s',
trim($projectNamespace, '\\'),
'\\%s\\%s',
$classInfo->getModuleName(),
$resolvableType
);
Expand Down

0 comments on commit 5c3cfb5

Please sign in to comment.