ayzanet/php-math

将PHP的数学资源转换为对象

1.3 2020-11-29 10:15 UTC

This package is auto-updated.

Last update: 2024-09-29 05:36:35 UTC


README

简单库,用于将PHP数学函数转换为对象。

特性

  • 高可读API
  • 数字操作
  • 支持链式方法!

安装

  • 需要 php >= 7.0
  • $ composer require ayzanet/php-math:^1.0

基本用法

// Normal usage
Math::abs(-56); // 56
Math::floor(-63.6); // 63
Math::pow(2,3); // 9
Math::isNan(10); // false
Math::round(5.6) // 6
Math::max([5, 3, 8]) // 8
Math::min([5, 3, 8]) // 3

// Use Chain Methods
(new Math(-10.6))::abs()::floor()::div(2)::get() // 5
(new Math(25))::sqrt()::pow(3)::get() // 125
只需查看其他方法API的代码!