Skip to content

Commit

Permalink
fix servive name resolution via namespace parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
roncodes committed Aug 15, 2024
1 parent 6677938 commit 64df312
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Traits/HasApiControllerBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ public function getApiServiceFromNamespace(?string $namespace = null)
*/
private function getServiceNameFromNamespace(string $namespace)
{
$segments = explode('\\', $namespace);
$targetSegment = count($segments) < 2 ? $segments[0] : $segments[1];
$segments = array_values(array_filter(explode('\\', $namespace)));
$targetSegment = count($segments) === 1 ? $segments[0] : $segments[1];
$slugifiedSegment = preg_replace('/(?<=[a-z])(?=[A-Z])/', '-', $targetSegment);
$slugifiedSegment = strtolower($slugifiedSegment);

Expand Down

0 comments on commit 64df312

Please sign in to comment.