granam/strict-float 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

granam/strict-float

最新稳定版本:2.1.1

Composer 安装命令:

composer create-project granam/strict-float

包简介

Base for lightweight float containers with strict checks

README 文档

README

Build Status

PHP does not provide scalar type hinting yet (planned for PHP 7.0).

For that reason, if we want to be sure about scalar type, a type-checking class is the only chance.

Note: requires PHP 5.4+

<?php
use Granam\Strict\Float\StrictFloat;
use Granam\Strict\Float\Exceptions\WrongParameterType;

$float = new StrictFloat(123.456);

// double(123.456)
var_dump($float->getValue());
// string(7) "123.456"
var_dump((string)$float);

$float = new StrictFloat(null, false /* explicitly non-strict*/);
// double(0)
var_dump($float->getValue());
// string(0)
var_dump((string)$float);

try {
  new StrictFloat(null);
} catch (WrongParameterType $floatException) {
  // Something get wrong: On strict mode expected float only, got NULL
  die('Something get wrong: ' . $floatException->getMessage());
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-05-18