Improve UserHelper::getInitials()
This commit is contained in:
@@ -34,7 +34,7 @@ class UserHelper extends Base
|
|||||||
{
|
{
|
||||||
$initials = '';
|
$initials = '';
|
||||||
|
|
||||||
foreach (explode(' ', $name) as $string) {
|
foreach (explode(' ', $name, 2) as $string) {
|
||||||
$initials .= mb_substr($string, 0, 1);
|
$initials .= mb_substr($string, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ class UserHelperTest extends Base
|
|||||||
$helper = new UserHelper($this->container);
|
$helper = new UserHelper($this->container);
|
||||||
|
|
||||||
$this->assertEquals('CN', $helper->getInitials('chuck norris'));
|
$this->assertEquals('CN', $helper->getInitials('chuck norris'));
|
||||||
|
$this->assertEquals('CN', $helper->getInitials('chuck norris #2'));
|
||||||
$this->assertEquals('A', $helper->getInitials('admin'));
|
$this->assertEquals('A', $helper->getInitials('admin'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user