承接 granam/boolean 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

granam/boolean

最新稳定版本:3.3.1

Composer 安装命令:

composer create-project granam/boolean

包简介

Lightweight boolean container with stand-alone converter

README 文档

README

Build Status Test Coverage

Hint

First of all, make sure you don't need just a simple built-in bool validation .

Internally behaves same way as (bool)$value, but

  • non-scalar values (arrays, resources, objects without __toString etc.) raises exception
  • objects with __toString magic method are converted to string by that, then to bool
  • null can be rejected by raise of an exception, if desired
<?php
use Granam\Boolean\Boolean;

$booleanFromInteger = new Boolean(12345);
// bool(true)
var_dump($booleanFromInteger->getValue());

$booleanFromString = new Boolean('124578');
// bool(true)
var_dump($booleanFromString->getValue());

$booleanFromFloatString = new Boolean('987.654');
// bool(true)
var_dump($booleanFromFloatString->getValue());

$booleanFromZero = new Boolean(0);
// bool(false)
var_dump($booleanFromZero->getValue());

$booleanFromNull = new Boolean(null, false /* not strict */);
// bool(false)
var_dump($booleanFromNull->getValue());
// ...

// exception is raised (\Granam\Boolean\Tools\Exceptions\WrongParameterType)
new Boolean(null); // implicitly strict - NULL is "unknown" state and therefore forbidden

统计信息

  • 总下载量: 17.15k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 5
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-10-29