2017 © Pedro Peláez
 

library universal-objects

image

lassehaslev/universal-objects

  • Monday, December 12, 2016
  • by LasseHaslev
  • Repository
  • 1 Watchers
  • 0 Stars
  • 79 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

lassehaslev/universal-objects

Create global classes with ease!, (*1)

Install

composer require lassehaslev/universal-objects

Usage

Extend global behavior:, (*2)

class MyClass extends LasseHaslev\UniversalObjects\Object {}

Create

Create a global instance simple with create or get. First time you call this method you create a new instance. But all the next time you call these methods, you simple return the existsing instance for that particular object., (*3)

MyClass::create(); // Create new or gets existing instance of my class
// or use alias "get" function
MyClass::get(); // alias for create()

Create different global object to use other places. Note that the first instance will still be used, and 'second' will only create a new instance, (*4)

$firstInstance = MyClass::create(); // Creates new instance
$secondInstance = MyClass::create( 'second' ); // Creates new instance

$firstInstance = MyClass::get(); // Get first instance
$secondInstance = MyClass::get( 'second' ); // Get second instance

To force create a new instance you can call createNew function, (*5)

$firstInstance = MyClass::create(); // Creates new instance
$firstInstance = MyClass::createNew(); // Creates new instance

Destroy

You can also destroy instances you have created. If you run create again, they will create new fresh instances, (*6)

$firstInstance = MyClass::create(); // Creates new instance
$secondInstance = MyClass::createNew( 'second' ); // Creates new instance

$firstInstance = MyClass::destroy(); // Deletes instance $firstInstance
$secondInstance = MyClass::destroy( 'second' ); // Deletes instance $seondInstance
$firstInstance = MyClass::create(); // Creates new instance
$secondInstance = MyClass::createNew( 'second' ); // Creates new instance

$firstInstance = MyClass::destroyAll(); // Destroy all instances of class ($firstInstance, $secondInstance)

Development

# Install dependencies
composer install

# Install dependencies for automatic tests
yarn

Runing tests

``` bash, (*7)

Run one time

npm run test, (*8)

Automaticly run test on changes

npm run dev ```, (*9)

The Versions

12/12 2016

dev-master

9999999-dev

  Sources   Download

The Development Requires

by Lasse S. Haslev

12/12 2016

0.1.0

0.1.0.0

  Sources   Download

The Development Requires

by Lasse S. Haslev

01/12 2016

0.0.1

0.0.1.0

  Sources   Download

The Development Requires

by Lasse S. Haslev