mordilion/mutils
最新稳定版本:v1.2.3
Composer 安装命令:
composer require mordilion/mutils
包简介
Useful little helpers
README 文档
README
MUtils is a collection of useful functions and to provide some PHP 8.0+ features for older PHP versions.
PHP 8.0+ Features
If you use the functions from this Library, it checks if you are using PHP 8.0+ and use then the internal functions (pass-through).
- Sorting Functions (They have a slow performance if it's not pass-through! - https://wiki.php.net/rfc/stable_sorting)
- asort, arsort, ksort, krsort, natcasesort, natsort, rsort, sort, uasort, uksort, usort
- String Functions
- str_contains, str_ends_with, str_starts_with
Useful Functions
- Array Functions - Functions to optimize working with arrays
- array_compare_flags, array_move_element, array_group_by, array_prefix_add, array_prefix_remove
- Bitwise Functions - Some useful functions to work with sets of bits.
- bit_set, bit_isset, bit_unset
- Reflection Functions - Useful functions to get ReflectionClass, ReflectionMethod and ReflectionProperty on inheritance
- get_reflection_class, get_reflection_method, get_reflection_property
Examples
Use of array functions
<?php $array = [128, 2, 16, 64, 8, 1, 32]; // or MUtils\Arrays::userAssociativeSort() MUtils\Arrays\uasort($array, static function ($left, $right) { return $left <=> $right; })
Use of string functions
<?php // or MUtils\Strings::startsWith() if (MUtils\Strings\str_starts_with('Some Text', 'Some')) { // ... }
Use of bit functions
<?php // or MUtils\Bits::isset() if (MUtils\Bits\bit_isset(12, 4)) { // ... }
Use of reflection functions
<?php // or MUtils\Objects::getReflectionMethod() $instance = new Something(); $method = MUtils\Objects\get_reflection_method($instance, 'foo'); if ($method) { $method->invoke($instance, 'arg'); // ... }
统计信息
- 总下载量: 17.34k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-02-24