bitandblack/helpers

Useful methods you may like

1.3.2 2020-06-04 07:14 UTC

This package is auto-updated.

Last update: 2020-08-04 07:47:24 UTC


README

PHP from Packagist Codacy Badge Latest Stable Version Total Downloads License composer.lock

Helpers

Useful methods you may like.

Installation

This library is available for the use with Composer. Add it to your project by running $ composer require bitandblack/helpers.

Use

All methods are defined static and can be used without the need of initializing an object. Also most of them are able to handle single input values as well as arrays.

There are useful methods to handle:

  • Arrays
    • ArrayHelper::usortMulti Sorts multidimensional array by their values.
    • ArrayHelper::uniqueArray Uniques an array be a given key.
    • ArrayHelper::getIfIsArray Returns the input if it's an array, otherwise false or a custom value.
    • ArrayHelper::getArray Returns the input as array.
    • ArrayHelper::getValueIfKeyExists Returns the value of an array based on it's key.
    • ArrayHelper::recurse Runs a function on an input, no matter if it's a string or an array.
  • Conditions
    • ConditionHelper::getIfIsset Returns the variable's value if it's set.
    • ConditionHelper::getIfNotNull Returns the variable if it's not null.
  • Numbers
    • NumberHelper::convertNumber Converts a number into a given format.
  • Requests
    • RequestHelper::sortUploadFiles Sort all uploaded images to a nice array.
  • Strings
    • SanitizeHelper::htmlEntities Returns the input converted by the htmlentities function.
    • SanitizeHelper::htmlEntityDecode Returns the input converted by the html_entity_decode function.
    • SanitizeHelper::htmlSpecialChars Returns the input converted by the htmlspecialchars function.
    • StringHelper::stringToBoolean Converts the input to boolean if possible.
    • StringHelper::stringToBooleanAdvanced Converts the input to boolean if possible and handles also yes and no.
    • StringHelper::stringToInt Converts the input to int if possible.
    • StringHelper::stringToFloat Converts the input to float if possible.
    • StringHelper::stringToNumber Converts the input to int or float if possible.
    • StringHelper::strReplaceMulti Replaces values in multidimensional arrays.
  • URLs
    • URLHelper::getContentByURL Returns the content of a page using allow_url_fopen or curl.
    • URLHelper::getScriptURL Returns the script url parameter.
  • XMLs
    • XMLHelper::hasGetOr Proofs if an attribute exists and returns its content or returns the option parameter instead.
    • XMLHelper::hasIsAttribute Checks if an XML element has an attribute with a given value.
    • XMLHelper::loadHTML Loads HTML safely and ignores errors.

Help

If you have any questions, feel free to contact us under helpers@bitandblack.com.