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

[11.x] Add pan format for String helper #53769

Conversation

alexanderkroneis
Copy link

This PR introduces another helper function on Str and Stringable. It formats a given string into a PAN.

PAN is a Primary Account Number which is used for credit card numbers and IBANs.

Str::pan('AT866000031866916134') // AT86 6000 0318 6691 6134
str('AT866000031866916134')->pan() // AT86 6000 0318 6691 6134

@Jubeki
Copy link
Contributor

Jubeki commented Dec 6, 2024

I would love to the following values also being correctly transformed into sets of 4 symbols, so that even with spaces, the correct result is given:

AT8 660 000 318 669 161 34
AT86 6000 0318 6691 6134

I normally used the following code for that:

trim(chunk_split(
    str_replace(' ', '', $value),
    4,
    ' '
))

@alexanderkroneis alexanderkroneis force-pushed the add-iban-as-string-helper branch from ed7f9e2 to 44ce2f2 Compare December 6, 2024 08:32
@alexanderkroneis
Copy link
Author

I would love to the following values also being correctly transformed into sets of 4 symbols, so that even with spaces, the correct result is given:

AT8 660 000 318 669 161 34
AT86 6000 0318 6691 6134

I normally used the following code for that:

trim(chunk_split(
    str_replace(' ', '', $value),
    4,
    ' '
))

Thanks, that a great input!

@taylorotwell
Copy link
Member

I think you could macro this into your project if needed. 👍

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

Successfully merging this pull request may close these issues.

4 participants