Download the PHP package phppackage/magic-class without Composer
On this page you can find all versions of the php package phppackage/magic-class. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download phppackage/magic-class
More information about phppackage/magic-class
Files in phppackage/magic-class
Download phppackage/magic-class
More information about phppackage/magic-class
Files in phppackage/magic-class
Vendor phppackage
Package magic-class
Short Description A magical PHP class
License MIT
Homepage http://github.com/phppackage/magic-class
Package magic-class
Short Description A magical PHP class
License MIT
Homepage http://github.com/phppackage/magic-class
Keywords magic
Please rate this library. Is it a good library?
Informations about the package magic-class
Magic Class
A magical PHP class, which can be treated as an array or an object, which toString's to json.
Install
Require this package with composer using the following command:
Usage example:
<?php
require 'vendor/autoload.php';
//
use PHPPackage\MagicClass;
// pre-initialize with constructor arguments
$magicClass = new MagicClass('some value');
// access as array or object
echo $magicClass[0] // some value
echo $magicClass->{0} // some value
// an empty instance
$magicClass = new MagicClass();
// add values
$magicClass['foo'] = 'BarBaz';
// access as array or object
echo $magicClass['foo']; // BarBaz
echo $magicClass->foo; // BarBaz
// variables can be invoked
$magicClass->object = new class {
private $foo = 'BarBaz';
public function getFoo()
{
return $this->foo;
}
};
echo $magicClass('object')->getFoo(); // BarBaz
// toString dumps to json
$magicClass['foo'] = 'BarBaz';
echo strval($magicClass); // {"foo": "BarBaz"}
// count elements
echo count($magicClass) // 1
// var_dump/print_r clean output
print_r($magicClass);
PHPPackage\MagicClass Object
(
[string] => BarBaz
)
Testing
Contributing
Please see CONTRIBUTING for details.
Credits
- Lawrence Cherone
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of magic-class with dependencies
PHP Build Version
Package Version
Requires
php Version
~5.6|~7.0
The package phppackage/magic-class contains the following files
Loading the files please wait ....