PHPackages                             khanhn-2612/php-calculator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. khanhn-2612/php-calculator

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

khanhn-2612/php-calculator
==========================

A basic calculator package for Laravel

v1.0.1(2mo ago)06MITPHP ^8.2

Since May 22Compare

[ Source](https://github.com/khanhn-2612/php-calculator)[ Packagist](https://packagist.org/packages/khanhn-2612/php-calculator)[ RSS](/packages/khanhn-2612-php-calculator/feed)WikiDiscussions Synced 3w ago

READMEChangelog (1)Dependencies (3)Versions (4)Used By (0)

php-calculator
==============

[](#php-calculator)

A basic calculator package for Laravel.

Requirements
------------

[](#requirements)

- PHP 8.2+
- Laravel 9 / 10 / 11 / 12

Installation
------------

[](#installation)

```
composer require khanhn-2612/php-calculator
```

Laravel auto-discovers the service provider via package auto-discovery.

Usage
-----

[](#usage)

### Direct instantiation

[](#direct-instantiation)

```
use KhanhN\Calculator\Calculator;

$calc = new Calculator();

// Basic arithmetic
$calc->add(2, 3);            // 5.0
$calc->subtract(5, 2);       // 3.0
$calc->multiply(2, 4);       // 8.0
$calc->divide(10, 2);        // 5.0

// Extra math
$calc->power(2, 3);          // 8.0
$calc->sqrt(16);             // 4.0
$calc->modulo(10, 3);        // 1.0
$calc->abs(-7);              // 7.0
$calc->percentage(200, 15);  // 30.0  (15% of 200)

// Rounding
$calc->round(3.456, 2);      // 3.46
$calc->floor(3.9);           // 3.0
$calc->ceil(3.1);            // 4.0
```

### Fluent chain API

[](#fluent-chain-api)

```
use KhanhN\Calculator\Calculator;

$result = Calculator::chain(100)
    ->add(50)
    ->subtract(20)
    ->multiply(2)
    ->divide(4)
    ->round(2)
    ->result(); // 65.0
```

### Via facade

[](#via-facade)

```
use KhanhN\Calculator\Facades\Calculator;

Calculator::add(2, 3);
Calculator::chain(100)->add(50)->result();
```

Testing
-------

[](#testing)

```
composer install
./vendor/bin/phpunit
```

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance87

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

64d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/265482983?v=4)[khanhn-2612](/maintainers/khanhn-2612)[@khanhn-2612](https://github.com/khanhn-2612)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/khanhn-2612-php-calculator/health.svg)

```
[![Health](https://phpackages.com/badges/khanhn-2612-php-calculator/health.svg)](https://phpackages.com/packages/khanhn-2612-php-calculator)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.3M347](/packages/psalm-plugin-laravel)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
