2017 © Pedro PelĂĄez
 

library object

Super Object that can handle everything you throw at him... or almost everything.

image

masnathan/object

Super Object that can handle everything you throw at him... or almost everything.

  • Tuesday, June 16, 2015
  • by MASNathan
  • Repository
  • 1 Watchers
  • 4 Stars
  • 76 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Object

Latest Version on Packagist Software License Build Status Total Downloads, (*1)

Super Object that can handle everything you throw at him..., (*2)

Install

Via Composer, (*3)

``` bash $ composer require masnathan/object, (*4)


## Usage ``` php use MASNathan\SuperObject; $object = new SuperObject(); $object->setMode('live'); $object->set('mode', 'live'); $object->mode = 'live'; $object['mode'] = 'live'; echo $object->getAppMode() // 'live' echo $object->get('app_mode') // 'live' echo $object->app_mode // 'live' echo $object['mode'] // 'live'

So... let's suppose you have an array like this:, (*5)

$myBigDataArray = array(
    'details' => array(
        'first_name' => 'André',
        'last_name' => 'Filipe',
        'email' => 'andre.r.flip@gmail.com',
        'social' => array(
            'github' => 'https://github.com/MASNathan',
            'twitter' => 'https://twitter.com/masnathan'
        )
    ),
    'account_info' => array(
        'admin' => true,
        'last_login' => 2015-06-13 13:37:00
    )
    'cart_items' => array(
        array('id' => 1337),
        // (...)
    )
);

Using the SuperObject class you can access it's information like this:, (*6)

$object = new SuperObject($myBigDataArray);

echo $object->getDetails()->getFirstName(); // 'André'
$object->getDetails()->isLastName('Roque'); // false
echo $object->getDetails()->getSocial()->getGithub(); // 'https://github.com/MASNathan'
echo $object->getDetails()->getSocial()->getFacebook(); // ''
$object->getAccountInfo()->isAdmin(); // true
$object->getAccountInfo()->unsetLastLogin(); // unsets $myBigDataArray['account_info']['last_login']

foreach ($object->getCartItems() as $item) {
    echo $item->getId(); // 1337
}

You can also retrive the contents of the SuperObject as an array or a StdClass:, (*7)

$object->toArray(); // array( ... )
$object->toObject(); // StdClass( ... )

And even serialize/ deserialize the object, (*8)

unserialize(serialize($object));
// or as json
json_decode(json_encode($object));

Change log

Please see CHANGELOG for more information what has changed recently., (*9)

Testing

bash $ composer test, (*10)

Contributing

Please see CONTRIBUTING for details., (*11)

Security

If you discover any security related issues, please email andre.r.flip@gmail.com instead of using the issue tracker., (*12)

Credits

License

The MIT License (MIT). Please see License File for more information., (*13)

The Versions

16/06 2015

dev-master

9999999-dev https://github.com/masnathan/object

Super Object that can handle everything you throw at him... or almost everything.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

data object handler

16/06 2015

v1.0.1

1.0.1.0 https://github.com/masnathan/object

Super Object that can handle everything you throw at him... or almost everything.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

data object handler

09/06 2015

v1.0.0

1.0.0.0 https://github.com/masnathan/object

Super Object that can handle everything you throw at him... or almost everything.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

data object handler

17/12 2014

dev-php5.3

dev-php5.3

Super Object that can handle everything you throw at him... or almost everything.

  Sources   Download

MIT