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

Add Arr method: toLocaleString() #15

Open
9 tasks
roberto-butti opened this issue Dec 29, 2021 · 4 comments
Open
9 tasks

Add Arr method: toLocaleString() #15

roberto-butti opened this issue Dec 29, 2021 · 4 comments
Assignees
Labels
enhancement New feature or request hacktoberfest

Comments

@roberto-butti
Copy link
Contributor

What

Add new method to Arr class, in src/Arr.php file

Description

The toLocaleString() method returns a string representing the elements of the array. The elements are converted to Strings using their toLocaleString methods and these Strings are separated by a locale-specific String (such as a comma “,”).
In PHP as far as I know there is no toLocaleString. My suggestion is to try to convert into locale string detecting the type

  • number_format() if number
  • date_format if it is date

see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toLocaleString

Checklist

  • implement method
  • write phpdoc for the function
  • write test in tests/ArrTest.php
  • execute composer format
  • execute composer test-coverage
  • check if your method has full test coverage
  • add method in changelog
  • update doc/arr.md adding a use case of the new method
  • update cheatsheet (examples/cheatsheet.php)
@roberto-butti roberto-butti added the enhancement New feature or request label Dec 29, 2021
@xanaDev
Copy link

xanaDev commented Oct 2, 2022

I'd like to work on this, can you assign it to me?

@xanaDev
Copy link

xanaDev commented Oct 6, 2022

@roberto-butti Hey there, I have just started looking at the issue and I have a couple of questions:

  • What does a typical input array look like (esp. the dates)
  • How is the locale set? do we guess it from the current env or should it be provided as a parameter

@sukuasoft
Copy link

@roberto-butti I saw this issue, I would like to know if I can still work on it. And if so, I have a question, in the types where objects, functions and resources are, what should I do, leave it blank and continue?

@roberto-butti
Copy link
Contributor Author

hello thank you for your availability. Yes if the elements is not translatable into a string, you can convert it in a empty string (like if null os used in an element)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hacktoberfest
Projects
None yet
Development

No branches or pull requests

3 participants