Skip to content

Commit

Permalink
Fixed initials algorithm for all caps names
Browse files Browse the repository at this point in the history
Signed-off-by: Tom Wright <[email protected]>
  • Loading branch information
betterthanclay committed Aug 12, 2024
1 parent 12f0d16 commit c6380d2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
* Fixed initials algorithm for all caps names

## v0.6.3 (2024-07-17)
* Updated Veneer dependency

Expand Down
10 changes: 7 additions & 3 deletions src/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
use DecodeLabs\Dictum;
use DecodeLabs\Dictum\Plugins\Number as NumberPlugin;
use DecodeLabs\Dictum\Plugins\Time as TimePlugin;


use DecodeLabs\Veneer;
use DecodeLabs\Veneer\LazyLoad;
use DecodeLabs\Veneer\Plugin;
Expand Down Expand Up @@ -125,7 +123,13 @@ public function initials(
$output = $name
->toUtf8()
->replace(['-', '_'], ' ')
->regexReplace('[^A-Za-z0-9\s]', '')
->regexReplace('[^A-Za-z0-9\s]', '');

if ($output->contains(' ')) {
$output = $output->toTitleCase();
}

$output = $output
->regexReplace('([^ ])([A-Z])', '\\1 \\2')
->toTitleCase()
->regexReplace('[^A-Z0-9]', '');
Expand Down

0 comments on commit c6380d2

Please sign in to comment.