Skip to content

Commit

Permalink
Merge pull request #10 from savannabits/development
Browse files Browse the repository at this point in the history
New Feature: Loop in Substitution until all keys are substituted.
  • Loading branch information
coolsam726 authored Oct 24, 2023
2 parents ddac0a8 + 5b407c9 commit 0a43d63
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Helpers/Framework.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ public function substitute(string $expression, array $substitutions = [], string
$keys = collect($substitutions)->keys()->map(fn ($key) => "{$substitutionIdentifier}{$key}");
$values = collect($substitutions)->values();

return Str::of($expression)->replace($keys->toArray(), $values->toArray())->toString();
$replacement = Str::of($expression)->replace($keys->toArray(), $values->toArray())->toString();
while (Str::of($replacement)->contains($keys)) {
$replacement = $this->substitute($replacement,$substitutions,$substitutionIdentifier);
}
return $replacement;
}

public function getByCode(Model | string $model, string|array $code)
Expand Down

0 comments on commit 0a43d63

Please sign in to comment.