2017 © Pedro Peláez
 

utility ary

A php array/stdClass alternative to store configs, options and more.

image

salarmehr/ary

A php array/stdClass alternative to store configs, options and more.

  • Sunday, March 4, 2018
  • by salarmehr
  • Repository
  • 1 Watchers
  • 8 Stars
  • 1,960 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 16 Versions
  • 68 % Grown

The README.md

Ary

Ary provides unified interface for ary/object. Really handy to store:, (*1)

  • arrays/objects those their items/properties varies conditionally.
  • storing registry, system configuration, env variables, etc.
  • when you perform a chain of action on an array/object, (*2)

    It's super cool and after a while you can not code in php without it., (*3)

Features

  1. You can access array items using -> or [''] syntax.
  2. You will get null if an index does not exists (instead of a nasty notification!)
  3. You can specify a default value for missing indexes.
  4. You can set/get a value within a deeply nested array using "dot" notation.
  5. A bunch of really handy methods: merge, only, search, toObject, ...
  6. Now, Ary extends Illuminate\Support\Collection class so all of its methods are available (https://laravel.com/docs/master/eloquent-collections)

Examples

~~~~~ // Instantiation $ary = new Ary(); // or simply $ary = ary();, (*4)

//Initialization $ary = ary(2, 4, 6, 8); // or $ary = ary([2, 4, 6, 8]); $ary = ary(['x' => 'foo', 'y' => 'bar']);, (*5)

//Assignment $ary->newItem=20; //or $ary['newItem']=20;, (*6)

//Retrieval $foo = $ary->x; //or $foo = $ary['x']; $missed = $ary->get('missed', 'Default value'); $ary->all(); // returns the simple php array;, (*7)

// works as regular arrays count($ary); //returns 3 unset($ary[0]); json_encode($ary);, (*8)

// deep assignment/retrieval $ary = ary(['products' => ['desk' => ['price' => 100]]]); $value = $ary['products.desk.price']; //100 $ary['production.table.weight']=200;, (*9)

~~~~~~, (*10)

Installation

Simply include '__DIR__.'/src/helper.php';, (*11)

or use Composer:, (*12)

composer require salarmehr/ary
  • The Ary() requires PHP 5.4 or above.
  • The ary() helper function requires PHP 5.6 or above.

Licence

MIT, (*13)

The Versions

04/03 2018

dev-master

9999999-dev

A php array/stdClass alternative to store configs, options and more.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Reza Salarmehr

29/11 2017

v0.11

0.11.0.0

A php array/stdClass alternative to store configs, options and more.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Reza Salarmehr

17/09 2017

v0.10

0.10.0.0

A php array/stdClass alternative to store configs, options and more.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Reza Salarmehr

18/03 2016

v0.9

0.9.0.0

A php array/stdClass alternative to store configs, options and more.

  Sources   Download

MIT

The Requires

 

by Reza Salarmehr

18/03 2016

v0.91

0.91.0.0

A php array/stdClass alternative to store configs, options and more.

  Sources   Download

MIT

The Requires

 

by Reza Salarmehr

18/03 2016

v0.9.1

0.9.1.0

A php array/stdClass alternative to store configs, options and more.

  Sources   Download

MIT

The Requires

 

by Reza Salarmehr

18/03 2016

v0.8.1

0.8.1.0

A php array/stdClass alternative to store configs, options and more.

  Sources   Download

MIT

The Requires

 

by Reza Salarmehr

04/03 2016

v8.0

8.0.0.0

A php array/stdClass alternative to store configs, options and more.

  Sources   Download

MIT

The Requires

 

by Reza Salarmehr

04/03 2016

v0.81

0.81.0.0

A php array/stdClass alternative to store configs, options and more.

  Sources   Download

MIT

The Requires

 

by Reza Salarmehr

13/11 2015

v0.7

0.7.0.0

A php array/stdClass alternative to store configs, options and more.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Reza Salarmehr

09/11 2015

v0.6

0.6.0.0

A php array/stdClass alternative to store configs, options and more.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Reza Salarmehr

09/11 2015

v0.5

0.5.0.0

A php array/stdClass alternative to store configs, options and more.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Reza Salarmehr

05/11 2015

v0.4

0.4.0.0

A php array/stdClass alternative to store configs, options and more.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Reza Salarmehr

19/10 2015

v0.3

0.3.0.0

A php array/stdClass alternative to store configs, options and more.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Reza Salarmehr

17/10 2015

v0.2

0.2.0.0

A php array/stdClass alternative to store configs, options and more.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Reza Salarmehr

01/10 2015

v0.1

0.1.0.0

A php array/stdClass alternative to store configs, options and more.

  Sources   Download

MIT

by Avatar Reza