p-nerd/util

PHP 函数的对象封装器

v0.04 2024-07-06 16:16 UTC

This package is auto-updated.

Last update: 2024-09-12 17:57:56 UTC


README

PHP 函数的对象封装器。

此包提供了针对 PHP 函数的精心挑选、组织化和一致的面向对象 API。

安装

composer require p-nerd/util

示例用法

PArray

use PNerd\Util\PArray;

// Example usage of PArray
$array = [1, 2, 3, 4, 5];
$pArray = new PArray($array);

$pArray
    // Map example
    ->map(function ($value, $key) {
        return $value * 2;
    })
    // Filter example
    ->filter(function ($value, $key) {
        return $value % 2 == 0;
    });

// Output results after filtering
echo "Mapped and filtered array: ";
print_r($pArray->get());

// Find example after filtering
$foundValue = $pArray->find(function ($value, $key) {
    return $value > 3;
});

// Output result of find operation
echo "First value > 3 found: ";
var_dump($foundValue);

许可证

此项目采用 MIT 许可证。有关更多详细信息,请参阅 LICENSE 文件。

联系

如有问题或反馈,请联系 shihab4t@gmail.com 或访问 developershihab.com