Improve UserHelper::getInitials()

This commit is contained in:
Frederic Guillot 2016-03-27 17:20:21 -04:00
parent ab082bdb2b
commit a20f4f2904
2 changed files with 2 additions and 1 deletions

View File

@ -34,7 +34,7 @@ class UserHelper extends Base
{
$initials = '';
foreach (explode(' ', $name) as $string) {
foreach (explode(' ', $name, 2) as $string) {
$initials .= mb_substr($string, 0, 1);
}

View File

@ -15,6 +15,7 @@ class UserHelperTest extends Base
$helper = new UserHelper($this->container);
$this->assertEquals('CN', $helper->getInitials('chuck norris'));
$this->assertEquals('CN', $helper->getInitials('chuck norris #2'));
$this->assertEquals('A', $helper->getInitials('admin'));
}