slashequip / sumy
Simple, chainable calculation library.
v0.3.1
2021-01-09 22:28 UTC
Requires
- php: ^7.1|^8.0
Requires (Dev)
- pestphp/pest: ^1.0
README
Sumy is a simple, chainable calculation library.
It started as a simple class in one of our projects but after needing and implementing the class in other projects we decided to turn it into a reusable package.
Here is a quick example:
$sumy = new Sumy(); $sumy->add(100)->divide(2); $sumy->get(); // 50
Installation
You can install this package by using Composer:
composer require slashequip/sumy
Getting Started
Sumy is super simple to use, first you need to initialize an instance of Sumy in your project, you can do this a few ways:
$sumyOne = new Sumy(); $sumyOne->get(); // 0 $sumyTwo = new Sumy(100); $sumyTwo->get(); // 100 $sumyThree = new Sumy($sumyTwo); $sumyThree->get() // 100
Math
$sumy = new Sumy(1000); $sumy->add(140)->get(); // 1140
Chaining
All Sumy's math methods can be chained:
$sumy = new Sumy(100); $sumy->add(400)->mulitply(4)->divide(2)->subtract(39)->sqrt()->pow(3); $sumy->get(); //29791
Licence
Copyright 2021 SlashEquip OÜ.
Distributed under the MIT licence. See LICENCE.txt for further information.