| Recommend this page to a friend! | 
| Info | Documentation | Reputation | Support forum | Blog | Links | 
| Ratings | Unique User Downloads | Download Rankings | ||||
| Not enough user ratings | Total: 218 | All time:  8,291 This week: 455 | ||||
| Version | License | PHP version | Categories | |||
| masnathan-object 1.0.1 | MIT/X Consortium ... | 5.4 | PHP 5, Data types | 
| Description | Author  | |||
This class can set and get variables, call objects in many ways. Innovation Award 
  | 
Super Object that can handle everything you throw at him...
Via Composer
$ composer require masnathan/object
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:
$myBigDataArray = array(
	'details' => array(
		'first_name' => 'André',
		'last_name' => 'Filipe',
		'email' => '[email protected]',
		'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:
$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`:
$object->toArray(); // array( ... )
$object->toObject(); // StdClass( ... )
And even serialize/ deserialize the object
unserialize(serialize($object));
// or as json
json_decode(json_encode($object));
Please see CHANGELOG for more information what has changed recently.
$ composer test
Please see CONTRIBUTING for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.
| File | Role | Description | ||
|---|---|---|---|---|
| Data | Auxiliary data | |||
| Lic. | License text | |||
| Doc. | Documentation | |||
| The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. | 
| Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
| 100% | 
  | 
  | 
| Applications that use this package | 
 If you know an application of this package, send a message to the author to add a link here.
| Related pages | 
| Packagist Details | 
| Github Repository |