Skip to content

Commit

Permalink
New Feature: Loop in Substitution until all keys are substituted.
Browse files Browse the repository at this point in the history
  • Loading branch information
coolsam726 committed Oct 24, 2023
1 parent c09f2ec commit 5b407c9
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 5b407c9

Please sign in to comment.