jeremykendall/ultra-facade

Implements the Facade pattern to build SplIterators.

1.0.0 2014-03-06 19:57 UTC

This package is auto-updated.

Last update: 2024-03-25 05:21:26 UTC


README

In the context of UltraFacade, a Facade is an object-oriented creational design pattern to implement the concept of facades and deals with the problem of creating objects without specifying the exact class of object that will be created.

A Concrete Implementation

The concrete implentation in this library, JeremyKendall\UltraFacade\SplIteratorFacade, is an example of how to properly use a Facade. It creates SPL Iterators based on a type string passed in at runtime. The type string is the name of the SPL Iterator with 'Iterator' removed (less typing FTW). The second optional argument is used to pass required params the the iterator's constructor.

$iterator = new SplIteratorFacade::facade('RecursiveDirectory', array(__DIR__));

While this specific facade implementation is production ready and should be used if you have a use case for it, the intent is simply to demonstrate how the Facade should be used.

Installation

Installation is handled via Composer.

{
    "require": {
        "jeremykendall/ultra-facade": "1.*"
    }
}

Please check the UltraFacade page at Packagist for the latest version.