aelora/truthy
最新稳定版本:1.0.1
Composer 安装命令:
composer require aelora/truthy
包简介
Add a simple isTruthy and isFalsy function to see if things are true-like or false-like
README 文档
README
isTruthy / isFalsy
Simple PHP package to add an isTruthy and isFalsy function.
And yes, I know this is simple to almost a silly level. But it's something that I found myself adding to a bunch of different PHP projects so it seemed like a perfect bit of code to build into a package.
Installation
Install using composer
composer require aelora/truthy
There are no settings.
Usage
Once loaded, there will be an isTruthy and isFalsy function in the global namespace.
The following values are considered falsy
- false
- null
- empty string
- 0
- 0.0
- empty array
- empty object
- strings "no", "n", "false", "f", "off", "null", "0", "0.0"
Everything else is considered truthy.
if (isTruthy($value)) { // Do something } if (isFalsy($value)) { // Do something }
Tests
composer test
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-07-21
