Hi-Folks / array

Arr class is built on top of the PHP array functions. Arr exposes methods for creating, managing, accessing to the array data structure.
https://packagist.org/packages/hi-folks/array
MIT License
15 stars 9 forks source link

Change the underlying data structure for Tables from array to Arr #51

Closed RoadSigns closed 2 years ago

RoadSigns commented 2 years ago

Summary

With this pull request, I've changed the underlying data structure of the rows within the Table class to be of type Arr instead of array. This allows us to lean on all of the methods within the Arr object instead of recreating them.

Since we are now using Arr as the data structure, this has meant that we have stopped the extension of the Arr class. This allows us to ensure that we aren't providing public methods from the Table class that don't work with a multidimensional array.

Implementing Countable

We are now implementing \Countable in the Table class. This will allow us to use methods like count() to count the number of rows within the Table without the need for users to access properties. However there is one available if needed $table->count().

Implementing Iterator

We are not implementing \Iterator in the Table class. This allows us to loop over the Table object using loops or array methods to access the rows.

Updating the Select and Except method parameters from array to variable-length argument lists

The method parameters have been updated from array to variable-length argument lists, this allows us to ensure that the arguments being passed in are the correct type and we aren't going to experience someone trying to get columns of type stdClass inside of the int or string.

Set and Unset in the Arr Class

Two new methods have been added to Arr class to allow people to set and unset elements within the Arr by their keys.

roberto-butti commented 2 years ago

Hi @RoadSigns , this PR looks amazing. Thank you!!!!!!!

I'm going to merge it into main. I will test a bit the main branch (after the merge) and then i will create a release. The release will be 0.1.0 (i want to increment the minor).