2017 © Pedro Peláez
 

library carnival

Create static facades from instances

image

aztech/carnival

Create static facades from instances

  • Monday, February 9, 2015
  • by thibaud-evaneos
  • Repository
  • 1 Watchers
  • 0 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Carnival

Build Status Scrutinizer Code Quality Code Coverage HHVM Support, (*1)

Carnival is a simple library to generate static facades from instance objects. In other words, it takes an object, hides it behind a generated static class, effectively transforming your object into a singleton as long as you access it from the static facade., (*2)

Installation

Composer is the only supported way of installing and using Carnival. From your project's root directory, run:, (*3)

composer require aztech/carnival

You must then include the Composer autoloader in the entry file of your application:, (*4)

<?php

require_once __DIR__ . 'vendor/autoload.php';

Dafuq is wrong with you ?

Probably a lot of things. But that fails to answer the question, why this library. Because !, (*5)

Ok, originally, I wrote it as a troll. But if anyone finds it useful, go ahead, have fun !, (*6)

And you're using eval ?

Isn't that the root of all evil ? Probably, but it's used in a constrained way, and honestly, if you plan on passing tainted data to Masquerade, allow me to ask dafuq is wrong with you ?, (*7)

So now that its uselessness is settled, how do I use it anyways ?

Simple, bind whatever object you want to a new, non-existing class name (you can even namespace your facade !) like that:, (*8)


// This call is only required once, you can place it in your application bootstrap or wherever. Aztech\Carnival\Masquerade::register(); // Bind an object to a class name Aztech\Carnival\Masquerade::bind('\Facades\SomeArray', new \SplObjectStorage()); // Use your facade Facades\SomeArray::attach(new \stdClass());

Yup, simple as that., (*9)

The Versions

09/02 2015

dev-master

9999999-dev

Create static facades from instances

  Sources   Download

MIT

The Requires

  • php >= 5.4

 

The Development Requires

aztech aztech-digital

09/02 2015

0.1.0

0.1.0.0

Create static facades from instances

  Sources   Download

MIT

The Requires

  • php >= 5.4

 

The Development Requires

aztech aztech-digital