mossengine/helper

PHP Class that streamlines usages of static method helpers without needing to load in or define all the helper classes

2.0.1 2021-06-25 17:30 UTC

This package is auto-updated.

Last update: 2024-11-04 20:45:25 UTC


README

A PHP library for calling many different helpers from a single point.

Source Code Download Package PHP Programming Language Build Status Codecov Code Coverage Read License Package downloads on Packagist

About

Helper functions are an important part of any project, however, depending on the implementation they can come at a small or great cost to system resources such as memory.

When you have an included functions file full of functions that you use throughout the project but not all at any one time, the cost you have here is memory allocation to store the functions ready for calling... Other practices with using Helper classes with smaller sets of dedicated static methods are an improvement, but you're still using memory to store those methods that are not needed.

This package allows you to call specific functions under certain categories without needing to load into memory anything more than what you need, it uses a dynamic loading style and also specifically designed helper classes for each specific method so that we only need to load what's needed.

A comparison of memory allocation between a full class of helper methods and this individual loading solution, the results was a 20KB allocation of memory vs 6KB. Larger sets of helper class methods can expect memory allocation sizes higher than 20KB... especially for more complex helper methods with more than a few lines of code.

Installation

Using composer to install

$ composer require mossengine/helper

Adding to package.json

{
    "require": {
        "mossengine/helper": "~1.0.0"
    }
}

Usage

Call helper method on a specific helper class

// Require the autoloader, normal composer stuff
require 'vendor/autoload.php';

// Call the Test method on the Test helper class
$result = Mossengine\Helper::Test()->Test();

Helpers

There are other helper classes you can use with this helper library

Mossengine/HelpersArray A library of array based helper methods to manipulate and analyse array structures.

Mossengine/HelpersStatement A library of statement based helper methods to compare and evaluate variable structures against each other.

Documentation

Read the docs for more details on Helper and how to call and extend with your own helper classes and methods