PLZ: A handy PHP library for lazy programmers
  • Namespace
  • Class
  • Tree
  • Todo

Namespaces

  • amekusa
    • plz
  • PHP

Classes

  • amekusa\plz\alt
  • amekusa\plz\arr
  • amekusa\plz\constant
  • amekusa\plz\dom
  • amekusa\plz\fn
  • amekusa\plz\num
  • amekusa\plz\obj
  • amekusa\plz\op
  • amekusa\plz\path
  • amekusa\plz\str
  • amekusa\plz\sys
  • amekusa\plz\T
  • amekusa\plz\type
  • amekusa\plz\xml

Exceptions

  • amekusa\plz\ErrorException
 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 
<?php namespace amekusa\plz; main::required;

/**
 * Function utilities
 *
 * To get started, place the following line around top of your code.
 * ```php
 * use amekusa\plz\fn;
 * ```
 */
abstract class fn {

    /**
     * Calls a function:`$X`
     *
     * Additionally:
     *
     * + If `$X` is not callable, returns `$Alt`
     * + If `$X` is not callable, And `$Alt` is callable, calls `$Alt`
     *
     * @param callable $X A function to call
     * @param mixed $Args *(optional)* Arguments to pass to `$X`. Pass an array for multiple parameters
     * @param mixed $Alt *(optional)* A fail-safe value
     * @return mixed A value `$X` returns or `$Alt`
     */
    static function call($X, $Args = null, $Alt = null) {
        if (!is_callable($X)) {
            if (is_callable($Alt)) {
                return isset($Args) ?
                    call_user_func_array($Alt, type::arr($Args)) :
                    call_user_func($Alt);
            }
            return $Alt;
        }
        return isset($Args) ?
            call_user_func_array($X, type::arr($Args)) :
            call_user_func($X);
    }
}
PLZ: A handy PHP library for lazy programmers API documentation generated by ApiGen