Skip to content

Add Arr method: toLocaleString() #15

@roberto-butti

Description

@roberto-butti

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)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions