PHP Classes

File: README.md

Recommend this page to a friend!
  Classes of zinsou A.A.E.Moïse   PHP Shortcut Classes   README.md   Download  
File: README.md
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: PHP Shortcut Classes
Create shorter name functions to create objects
Author: By
Last change: correct the composer required package vendor name
Date: 5 years ago
Size: 2,666 bytes
 

Contents

Class file image Download

Class Instantiation Shortcut for PHP

Build Status Scrutinizer Code Quality Build Status Code Intelligence Status

Library which create custom Shortcut for classes Instantiation.

Requires: PHP 5.3+

Why Create Shortcut for PHP classes Instantiation?

Typically you would create Shortcut for class instantiation if:

  1. You need something more customized just like PHP create arrays with the array() function .
  2. You want to be more productive avoiding the "new" keyword usage but also too long class name repetitive usage .
  3. Instead of a gain of productivity You just are nostalgic of the times when you were using Python or the old fashion style of javaScript when you were not load yourself of the "new" keyword to instantiate a new object.
  4. Just for the fun to do it.
  5. Because you are just crazy in love with functions -:).

How to use it

Require the library by issuing this command:

composer require manuwhat/Shortcut

Add require 'vendor/autoload.php'; to the top of your script.

Next, create a Shortcut, just like this:

use ezama/Shortcut;

create_Shortcut('fullQualifiedclassname'[,'chosen_Shortcut_name']);
create_Shortcut('ArrayIterator');

The Shortcut is once and forever until cache suppression automatically created and the code included then you can use it in your script:

$obj=chosen_Shortcut_name(); // ==> ### if no chosen name has been specified then you may use!
$obj=fullQualifiedclassname();// of course you must pass the arguments if the constructor require them at instantiation
$iterator=ArrayIterator([1,1,2,3,3]);

By default shortcuts are cached in a default directory but you can specify a custom directory path where shortcuts will be saved using

use ezama/Shortcut;
Shortcut::setDir('your/path/here');
create_Shortcut('fullQualifiedclassname'[,'chosen_Shortcut_name']);
create_Shortcut('ArrayIterator','AI');

Keep in mind that only one custom Shortcut can be defined per class and that only instantiable classes can be used.

To run unit tests

phpunit  ./tests