grooveland / helpers
一组简化工作流程的帮助工具
v1.0
2018-07-26 19:53 UTC
Requires
- h4kuna/number-format: ^3.0
- jasny/php-functions: ^3.3
This package is not auto-updated.
Last update: 2024-09-29 05:55:21 UTC
README
此软件包允许您在数据库中管理设置。
设置通过分组和数据类型(字符串、布尔值、整数、双精度、数组)进行处理
安装
Laravel
此软件包可以在Laravel 5.4或更高版本中使用。
您可以通过composer进行安装
composer require grooveland/helpers
在Laravel 5.5中,服务提供者将自动注册。在框架的较旧版本中,只需在config/app.php文件中添加服务提供者即可
'providers' => [
// ...
\Grooveland\Helpers\HelperServiceProvider::class,
];
用法
这是默认帮助器的列表
数组
/**
* Transform an stdClass, object with toArray method
* or simple var into array, the parameter is passed by reference
*
* @param &$data
* @return void
*/
to_array(&$data)
对象
/**
* Check if $value is a instance of Eloquent Collection
*
* @param any $value
* @return bool
*/
is_collection($value)
/**
* Transform an array, object with Object method
* or simple var into stdClass, the parameter is passed by reference
*
* @param $data
* @return void
*/
to_obj(&$data)
数字
/**
* Format number
*
* @param $number
* @param string $thousandSeparator
* @param string $decimalPoint
* @param int $decimals
* @return string
*/
format_number($number, string $thousandSeparator = '.', string $decimalPoint = ',', int $decimals = 2)
字符串
/**
* Truncate a string by a max of chars, optionally can add HTML entities, preserve tags and add ellipsis
*
* @param string $string
* @param int $max
* @param int $start
* @param bool $addHtmlEntities
* @param bool $cleanTags
* @param bool $ellipsis
* @return string
*/
str_truncate(string $string, int $max, int $start = 0, bool $addHtmlEntities = false, bool $cleanTags = true, bool $ellipsis = true) : string
/**
* Replace the first coincidence in a string
*
* @param string $from
* @param string $to
* @param string $content
* @return string
*/
function str_replace_first(string $from, string $to, string $content)
贡献
即将推出。
安全性
如果您发现任何与安全性相关的问题,请通过电子邮件发送至 develop@thegrooveland.com,而不是使用问题跟踪器。
致谢
许可
MIT许可(MIT)。有关更多信息,请参阅许可文件。