YaLinqo\Functions::init PHP Method

init() public static method

public static init ( )
    public static function init()
    {
        self::$identity = function ($x) {
            return $x;
        };
        /** @noinspection PhpUnusedParameterInspection */
        self::$key = function ($v, $k) {
            return $k;
        };
        /** @noinspection PhpUnusedParameterInspection */
        self::$value = function ($v, $k) {
            return $v;
        };
        self::$true = function () {
            return true;
        };
        self::$false = function () {
            return false;
        };
        self::$blank = function () {
        };
        self::$compareStrict = function ($a, $b) {
            if ($a === $b) {
                return 0;
            } elseif ($a > $b) {
                return 1;
            } else {
                return -1;
            }
        };
        self::$compareStrictReversed = function ($a, $b) {
            if ($a === $b) {
                return 0;
            } elseif ($a > $b) {
                return -1;
            } else {
                return 1;
            }
        };
        self::$compareLoose = function ($a, $b) {
            if ($a == $b) {
                return 0;
            } elseif ($a > $b) {
                return 1;
            } else {
                return -1;
            }
        };
        self::$compareLooseReversed = function ($a, $b) {
            if ($a == $b) {
                return 0;
            } elseif ($a > $b) {
                return -1;
            } else {
                return 1;
            }
        };
        self::$compareInt = function ($a, $b) {
            return $a - $b;
        };
        self::$compareIntReversed = function ($a, $b) {
            return $b - $a;
        };
    }

Usage Example

示例#1
0
文件: Linq.php 项目: athari/yalinqo
<?php

/**
 * Global functions and initialization.
 * @author Alexander Prokhorov
 * @license Simplified BSD
 * @link https://github.com/Athari/YaLinqo YaLinqo on GitHub
 */
\YaLinqo\Functions::init();
\YaLinqo\Utils::init();
if (!function_exists('from')) {
    /**
     * Create Enumerable from an array or any other traversible source.
     * @param array|\Iterator|\IteratorAggregate|\YaLinqo\Enumerable $source
     * @throws \InvalidArgumentException If source is not array or Traversible or Enumerable.
     * @return \YaLinqo\Enumerable
     * @see \YaLinqo\Enumerable::from
     */
    function from($source)
    {
        return \YaLinqo\Enumerable::from($source);
    }
}
All Usage Examples Of YaLinqo\Functions::init