Skip to content

Commit

Permalink
Merge pull request #88 from Laravel-Lang/2.x
Browse files Browse the repository at this point in the history
Added description when cutting long messages
  • Loading branch information
andrey-helldar authored Dec 20, 2024
2 parents e1635c4 + f2ab03f commit 963bff8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/Providers/StringServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ class StringServiceProvider extends ServiceProvider
{
public function boot(): void
{
Stringable::macro('short', function (int $limit): Stringable {
Stringable::macro('short', function (int $limit, string $end = '...and more...'): Stringable {
if ($this->length() <= $limit) {
return $this;
}

$value = $this->value();

while ($limit < Str::length($value)) {
Expand All @@ -23,7 +27,7 @@ public function boot(): void
$value = $lines->implode("\n");
}

return new Stringable($value);
return new Stringable($value . "\n" . $end);
});
}
}

0 comments on commit 963bff8

Please sign in to comment.