Skip to content

ramazancetinkaya/percentage-calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Percentage Calculator Library

License Latest Version PHP GitHub Issues GitHub Forks GitHub Stars

A powerful and modern PHP library for performing various percentage calculations.

Report a Bug · New Pull Request

🌟 Star this Repository!

If you find the Percentage Calculator library helpful or interesting, consider giving it a star! ⭐️

Your star helps us grow and motivates us to continue improving the library. It also makes it easier for others to discover and benefit from this project.

How to Star?

  1. Login to Your GitHub Account: You need to have a GitHub account.
  2. Visit the Repository: Go to the Percentage Calculator Repository.
  3. Click the Star Button: On the top-right corner of the page, you'll find a "Star" button. Click on it!

That's it! Thank you for your support! 🚀

Table of Contents

Features

  • Calculate the percentage of a number.
  • Calculate the percentage change between two numbers.
  • Increase a number by a percentage.
  • Decrease a number by a percentage.

Installation

You can install this library via Composer. Run the following command:

composer require ramazancetinkaya/percentage-calculator

Usage

require_once 'vendor/autoload.php';

use ramazancetinkaya\PercentageCalculator;

$calculator = new PercentageCalculator();

Examples

try {
    // Calculate percentage
    $result = $calculator->calculatePercentage(250, 20);
    echo "20% of 250 is: " . $result . "\n";

    // Calculate percentage change
    $change = $calculator->calculatePercentageChange(100, 75);
    echo "Percentage change from 100 to 75 is: " . $change . "%\n";

    // Increase by percentage
    $increase = $calculator->increaseByPercentage(50, 25);
    echo "50 increased by 25% is: " . $increase . "\n";

    // Decrease by percentage
    $decrease = $calculator->decreaseByPercentage(80, 10);
    echo "80 decreased by 10% is: " . $decrease . "\n";
} catch (InvalidArgumentException $e) {
    echo "Error: " . $e->getMessage();
}

Contributing

Contributions are welcome! Please fork the repository and create a pull request.

Credits

This library was made possible by the following awesome contributors:

Special thanks to the following resources:

If you've contributed to this project and your name is not listed, please let us know, and we'll add you!

Thank you to everyone who has helped make this project better!

License

This project is licensed under the MIT License. For more details, see the LICENSE file.