PHP Classes

PHP Shortcut Classes: Create shorter name functions to create objects

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 98 All time: 9,836 This week: 660Up
Version License PHP version Categories
shortcut 1.0MIT/X Consortium ...5PHP 5, Language, Code Generation
Description 

Author

This package can create shorter name functions to create objects.

It can generate PHP code that is equivalent to create objects of given classes with eventual construction parameters, so it takes typing less code to create those class parameters.

The generate code for shortcuts is stored in a given directory so it can be cached and executed faster next time it is called.

Innovation Award
PHP Programming Innovation award nominee
April 2019
Number 4
In PHP there are many functions useful functions that have long names. Therefore they take more time to type especially when you use them many times.

This package can help reducing the time it is necessary to enter the names of those functions in the PHP scripts that they are used by creating shortcuts that are assigned to class functions with shorter names.

Manuel Lemos
Picture of zinsou A.A.E.Moïse
  Performance   Level  
Name: zinsou A.A.E.Moïse <contact>
Classes: 50 packages by
Country: Benin Benin
Innovation award
Innovation award
Nominee: 23x

Winner: 2x

Documentation

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

  Files folder image Files (8)  
File Role Description
Files folder imagesrc (2 files)
Files folder imagetests (1 file)
Accessible without login Plain text file .travis.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files (8)  /  src  
File Role Description
  Plain text file Shortcut.php Class Class source
  Plain text file shortcutQueryBuilder.php Class Class source

  Files folder image Files (8)  /  tests  
File Role Description
  Plain text file ShortcutTest.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:98
This week:0
All time:9,836
This week:660Up