gettonline / pipeit
PHP 7 及以上版本缺失的管道操作符
1.0.0
2021-07-28 23:02 UTC
Requires
- php: ^7
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- pestphp/pest: ^1.11
This package is auto-updated.
Last update: 2024-09-11 20:26:58 UTC
README
PHP 7 及以上版本缺失的管道操作符。
安装
您可以通过 composer 安装此包
composer require gettonline/pipeit
用法
简单
pipe('foo bar') ->strtoupper() ->value // FOO BAR
值位于不同位置
并非所有函数都需要将值作为第一个参数,使用 PIPE_IT
您可以移动值参数。
pipe(' hello there') ->trim() ->str_replace('there', 'world', PIPE_IT) ->ucwords() ->value // Hello World
使用闭包
pipe('gettonline.com') (function ($v) { return 'https://' . $v; }) ->value // https://gettonline.com
自动转换为字符串
print pipe([1,2,3]) ->array_sum() // 6
测试
composer test
变更日志
请参阅 CHANGELOG 了解最近更改的详细信息。
贡献
请参阅 CONTRIBUTING 了解详细信息。
鸣谢
许可证
MIT 许可证(MIT)。请参阅 许可证文件 了解更多信息。