javaguirre/php-extended-array

dev-master 2015-06-18 17:11 UTC

README

Build Status

Just a simple extension of the PHP array using ArrayObject

Install

Edit your composer.json file to require javaguirre/php-extended-array and run composer update

"require": {
    "javaguirre/php-extended-array": "dev-master"
}

Usage

<?php

use TA\ExtendedArray\Type\ExtendedArray;

$fruits = new ExtendedArray(
    array(
        'tropical' => 'pineapple',
        'farm'     => 'strawberry'
    )
);

$fruits->has('tropical');

// true

$fruits->hasOne(array('tropical', 'asian'));

// true

$fruits->hasAll(array('tropical', 'asian'));

// false

$fruits->get('canary', 'banana');

// 'banana'

$fruits->get('tropical', 'banana');

// 'pineapple'

$fruits->getSubArray(array('tropical'));

// array('tropical' => 'pineapple');

$fruits->toArray();

// array('tropical' => 'pineapple', 'farm' => 'strawberry');

Key access

You can access properties as If it was an object or an array

$fruits->tropical;

// 'pineapple'

$fruits['tropical'];

// 'pineapple'

LICENSE

MIT License