2017 © Pedro Peláez
 

library collection

Can convert array to collection objects and back to array

image

mibexx/collection

Can convert array to collection objects and back to array

  • Monday, May 15, 2017
  • by mibexx
  • Repository
  • 1 Watchers
  • 0 Stars
  • 14 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Collection-Object

Collections to use as objects for lists.
Can convert arrays to collections and collections to arrays.
Collections are iterable., (*1)

Installation

composer require mibexx/collection, (*2)

Configuration

There is no configuration needed, (*3)

Usage

Convert array to collection:, (*4)

use mibexx\collection\Collection\Collection;
use mibexx\collection\Parser\CollectionParser;

$list = [
    'foo' => 'bar',
    'fuzz' => [
        'foo' => 'buzz'
    ]
];

$parser = new CollectionParser();
$collection = new Collection();
$parser->convertToCollection($list, $collection);

echo $collection->get('foo')->get(); // prints bar
echo $collection->get('fuzz')->get('foo')->get(); // prints buzz

Create collection and convert to array:, (*5)

use mibexx\collection\Collection\Collection;
use mibexx\collection\Parser\ArrayParser;

$parser = new ArrayParser();
$collection = new Collection();

$fuzz = new Collection();
$fuzz->set('foo', new SimpleElement('buzz'));

$collection->set('foo', new SimpleElement('bar'));
$collection->set('fuzz', new CollectionElement($fuzz));

$newList = $parser->convertToArray($collection);

print_r($newList);
/* equal to:
array(
    'foo' => 'bar',
    'fuzz' => [
        'foo' => 'buzz'
    ]
)
*/

The Versions

15/05 2017

dev-master

9999999-dev

Can convert array to collection objects and back to array

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Mike Bertram

01/05 2017

v0.1.2

0.1.2.0

Can convert yaml to collection objects and back to yaml

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Mike Bertram

30/04 2017

v0.1.1

0.1.1.0

Can convert yaml to collection objects and back to yaml

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Mike Bertram

30/04 2017

v0.1.0

0.1.0.0

Can convert yaml to collection objects and back to yaml

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Mike Bertram