2017 © Pedro Peláez
 

library magic-class

A magical PHP class

image

phppackage/magic-class

A magical PHP class

  • Thursday, February 8, 2018
  • by lcherone
  • Repository
  • 1 Watchers
  • 1 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 25 % Grown

The README.md

Magic Class

Build Status StyleCI Scrutinizer Code Quality Code Coverage Packagist Version Packagist Downloads, (*1)

A magical PHP class, which can be treated as an array or an object, which toString's to json., (*2)

Install

Require this package with composer using the following command:, (*3)

``` bash $ composer require phppackage/magic-class, (*4)


### 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 ``` bash $ composer test

Contributing

Please see CONTRIBUTING for details., (*5)

Credits

License

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

The Versions

08/02 2018

dev-master

9999999-dev http://github.com/phppackage/magic-class

A magical PHP class

  Sources   Download

MIT

The Requires

  • php ~5.6|~7.0

 

The Development Requires

magic

08/02 2018

v1.0.2

1.0.2.0 http://github.com/phppackage/magic-class

A magical PHP class

  Sources   Download

MIT

The Requires

  • php ~5.6|~7.0

 

The Development Requires

magic

08/02 2018

v1.0.1

1.0.1.0 http://github.com/phppackage/magic-class

A magical PHP class

  Sources   Download

MIT

The Requires

  • php ~5.6|~7.0

 

The Development Requires

magic

08/02 2018

v1.0.0

1.0.0.0 http://github.com/phppackage/magic-class

A magical PHP class

  Sources   Download

MIT

The Requires

  • php ~5.6|~7.0

 

The Development Requires

magic