germania-kg / nullfactory
可调用的工厂,返回 null 或任何其他默认值
1.0.2
2022-03-30 10:01 UTC
Requires (Dev)
- php-coveralls/php-coveralls: ^2.0
- phpunit/phpunit: ^5.7|^6.0|^7.0
This package is auto-updated.
Last update: 2024-08-29 04:48:29 UTC
README
使用 Composer 安装
$ composer require germania-kg/nullfactory
使用方法
<?php use Germania\NullFactory\NullFactory; $nf = new NullFactory; $result = $nf( "anything" ); // null
为了使 NullFactory 返回其他内容,请将其传递给构造函数
<?php use Germania\NullFactory\NullFactory; $default_value = array("foo", "bar"); $nf = new NullFactory( $default_value ); $result = $nf( "anything" ); // array("foo", "bar")
NullFactory 也接受 PSR3-Logger,默认为 NullLogger
<?php use Germania\NullFactory\NullFactory; use Psr\Log\NullLogger; $nf = new NullFactory( null, new NullLogger ); $result = $nf( "anything" );
问题
查看 完整问题列表。
路线图
填写计划或期望的功能
开发
$ git clone https://github.com/GermaniaKG/NullFactory.git
$ cd NullFactory
$ composer install
单元测试
可以将 phpunit.xml.dist
复制到 phpunit.xml
并根据您的需求进行调整,或者保持不变。运行 PhpUnit 测试或 composer 脚本,如下所示
$ composer test # or $ vendor/bin/phpunit