bagsiz / easy-functions
此包的最新版本(v1.1.2)没有可用的许可证信息。
Laravel 包,提供有用且易于使用的 PHP 函数
v1.1.2
2019-09-09 10:34 UTC
Requires
- php: ^7.2
- illuminate/database: ~5.8.0
- laravel/framework: ^5.4.0
Requires (Dev)
- orchestra/testbench: ~3.8.0
- phpunit/phpunit: ^7.5|^8.0
This package is auto-updated.
Last update: 2024-09-29 05:42:15 UTC
README
Laravel 包,提供有用且易于使用的函数
安装
此包可以通过 Composer 安装。
composer require bagsiz/easy-functions
函数
checkFieldForRandom
此函数旨在检查模型字段与随机值,并返回该值
用法
例如,我们想检查 App\User 模型的 id 字段,你应该写;
function checkUserModel() { $user = new User(); $return EasyFunction::checkFieldForRandom($user, 'id', 'int', 8); }
checkFieldForRandom($model, string $field, string $type, int $length)
- $model = 模型的集合
- $fields = 模型字段 -> 字符串
'field' - $type = 你想生成的值的类型 -> 字符串
'str'或整数'int'。默认'str' - $length = 你想生成的值的长度 -> 整数
8。默认8
decimalToTime
此函数旨在将带有小数的整数转换为时间字符串
用法
function someFunction() { $timeString = EasyFunction::decimalToTime(936437.85); // Should return "10:20:07:17.85" }
decimalToTime(int $decimal)
- $decimal = 小数部分必须有一个点。 (例如:23.56)
测试
./vendor/bin/phpunit