Fermat PHP 数据统计包 项目简介
Fermat 是一个 PHP 开发包,可以对任意规模的数据进行数学和统计。示例代码1:<?php
use Samsara\Fermat\Numbers;
$five = Numbers::make(Numbers::IMMUTABLE, 5);
$ten = Numbers::make(Numbers::IMMUTABLE, '10');
echo $five->add($ten); // Prints: "15"示例代码2:<?php
use Samsara\Fermat\Values\ImmutableNumber;
use Samsara\Fermat\Values\ImmutableFraction;
$five = new ImmutableNumber(5);
$oneQuarter = new ImmutableFraction(1, 4);
echo $five->add($oneQuarter); // Prints: "5.25"
// The asDecimal() method is called on $oneQuarter
echo $oneQuarter->add($five); // Prints: "21/4"
// Calls getValue() on $five and instantiates a new ImmutableFraction
use Samsara\Fermat\Numbers;
$five = Numbers::make(Numbers::IMMUTABLE, 5);
$ten = Numbers::make(Numbers::IMMUTABLE, '10');
echo $five->add($ten); // Prints: "15"示例代码2:<?php
use Samsara\Fermat\Values\ImmutableNumber;
use Samsara\Fermat\Values\ImmutableFraction;
$five = new ImmutableNumber(5);
$oneQuarter = new ImmutableFraction(1, 4);
echo $five->add($oneQuarter); // Prints: "5.25"
// The asDecimal() method is called on $oneQuarter
echo $oneQuarter->add($five); // Prints: "21/4"
// Calls getValue() on $five and instantiates a new ImmutableFraction