keerill/php-java-optional
最新稳定版本:v1.0.2
Composer 安装命令:
composer require keerill/php-java-optional
包简介
Full implementation of Java8 Optional for PHP
README 文档
README
Full implementation of JAVA8 Optional for PHP
Usage
// ofEmpty refers Optional#empty() in java // It is renamed as ofEmpty() because of empty() is reserved by PHP Optional::ofEmpty() ->isPresent(); // false Optional::of('value') ->orElse('elseValue'); // value Optional::ofEmpty() ->orElseThrow(fn () => new InvalidArgumentException()); // throws exception Optional::ofEmpty() ->filter(fn ($a) => (int) $a); // function is not executed Optional::of(5) ->map(fn ($a) => $a * 2) ->get(); // returns 10 Optional::ofEmpty() ->orElseGet(fn () => 10); // returns 10
Installation
composer require keerill/php-java-optional
Resources
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 1.71k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2023-04-11