定制 mugesh/calculator 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

mugesh/calculator

最新稳定版本:v1.0.1

Composer 安装命令:

composer require mugesh/calculator

包简介

A simple calculator package for PHP

README 文档

README

Latest Version on Packagist Total Downloads Monthly Downloads Daily Downloads PHP Version Required License on Packagist

Build Status Last Commit Open Issues Pull Requests GitHub Stars GitHub Forks

Mugesh Calculator

A simple and lightweight calculator package for PHP that provides basic arithmetic operations.

Installation

You can install this package via Composer:

composer require mugesh/calculator

Usage

<?php
require_once 'vendor/autoload.php';

use Mugesh\Calculator\Calculator;

$calc = new Calculator();

// Basic operations
echo $calc->add(5, 3);        // 8
echo $calc->subtract(10, 4);  // 6
echo $calc->multiply(6, 7);   // 42
echo $calc->divide(15, 3);    // 5

// Advanced operations
echo $calc->percentage(200, 15);  // 30 (15% of 200)
echo $calc->power(2, 8);          // 256
echo $calc->sqrt(64);             // 8

Available Methods

  • add(float $a, float $b): float - Addition
  • subtract(float $a, float $b): float - Subtraction
  • multiply(float $a, float $b): float - Multiplication
  • divide(float $a, float $b): float - Division (throws exception for division by zero)
  • percentage(float $value, float $percentage): float - Percentage calculation
  • power(float $base, float $exponent): float - Power calculation
  • sqrt(float $number): float - Square root (throws exception for negative numbers)

Testing

Run the test suite:

composer test

Or using PHPUnit directly:

vendor/bin/phpunit

Requirements

  • PHP 7.4 or higher

License

This package is open-sourced software licensed under the MIT license.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-07-02