Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: Exclusion of Prepositions and Modification of Initials #148

Open
bsf-25 opened this issue Nov 13, 2023 · 0 comments
Open

Enhancement: Exclusion of Prepositions and Modification of Initials #148

bsf-25 opened this issue Nov 13, 2023 · 0 comments

Comments

@bsf-25
Copy link

bsf-25 commented Nov 13, 2023

I would like to propose an enhancement to the current functionality of the component. Currently, prepositions such as "de" or "das" in full names are included in the component's display. I suggest that these prepositions be excluded, and the preference be given to displaying the initials of the first and last names.

Current Behavior:
For example, with the name "Maria das Graças Rodrigues," the current display is "Md."

Desired Behavior:
I propose that the display exclude prepositions, resulting in "MR" for the same name. Additionally, the function should respect the desired length for the displayed initials.

Implementation Suggestion:
To implement this enhancement, I recommend updating the getInitialFromMultipleWords function in the laravolt/avatar/src/Generator/DefaultGenerator.php file as follows:

protected function getInitialFromMultipleWords($words, $length)
{
    // Get the first letter of the first name
    $firstInitial = Str::substr($words->first(), 0, 1);

    // Get the first letter of the last name
    $lastInitial = Str::substr($words->last(), 0, 1);

    // Concatenate the initials and limit the length according to the $length variable
    $result = $firstInitial . $lastInitial;

    return Str::substr($result, 0, $length);
}

It's important to note that, despite the existence of the $length parameter, the function currently returns only two initials: the first and last names. Adjustments are needed to accommodate the desired variable length for initials.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant