PHPackages                             abdulbaset/convert-numbers - 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. abdulbaset/convert-numbers

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

abdulbaset/convert-numbers
==========================

A PHP package to convert numbers to words and currencies in multiple languages

1.0.0(1y ago)310MITPHPPHP &gt;=7.4

Since Jan 29Pushed 1y ago1 watchersCompare

[ Source](https://github.com/AbdulbasetRS/Convert-Numbers)[ Packagist](https://packagist.org/packages/abdulbaset/convert-numbers)[ Docs](https://digitalatum.com)[ RSS](/packages/abdulbaset-convert-numbers/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

[![Thumbnail](docs/thumbnail.png)](docs/thumbnail.png)

Convert Numbers
===============

[](#convert-numbers)

A comprehensive PHP package for number conversion, supporting multiple languages and various conversion types.

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

[](#installation)

Install the package via Composer:

```
composer require abdulbaset/convert-numbers
```

Usage
-----

[](#usage)

### Basic Number Conversion

[](#basic-number-conversion)

```
use Abdulbaset\ConvertNumbers\ConvertNumbers;

// English (default)
echo ConvertNumbers::toWords(42); // "forty-two"
echo ConvertNumbers::toWords(1234.56); // "one thousand two hundred thirty-four point five six"

// Arabic
echo ConvertNumbers::toWords(42, 'ar'); // "اثنان و أربعون"
echo ConvertNumbers::toWords(1234.56, 'ar'); // "ألف و مائتان و أربعة و ثلاثون فاصلة خمسة ستة"

// French
echo ConvertNumbers::toWords(42, 'fr'); // "quarante-deux"
```

### Currency Conversion

[](#currency-conversion)

```
// Basic currency to words
echo ConvertNumbers::currencyToWords(1234.56, 'USD');
// "one thousand two hundred thirty-four dollars and fifty-six cents only"

// Arabic currency
echo ConvertNumbers::currencyToWords(1234.56, 'EGP', 'ar');
// "ألف و مائتان و أربعة و ثلاثون جنيه مصري و ستة و خمسون قرش فقط لا غير"

// Currency formatting
echo ConvertNumbers::currencyFormat(1234567.89, 'USD', 'en', true); // "1,234,567.89 $"
echo ConvertNumbers::currencyFormat(1234567.89, 'EGP', 'ar', true); // "١٬٢٣٤٬٥٦٧٫٨٩ ج.م"
```

### File Size Formatting

[](#file-size-formatting)

```
// Basic file size formatting
echo ConvertNumbers::toFileSize(1024); // "1.00 KB"
echo ConvertNumbers::toFileSize(1024 * 1024); // "1.00 MB"

// Arabic formatting
echo ConvertNumbers::toFileSize(1024, 'ar'); // "١٫٠٠ كيلوبايت"
echo ConvertNumbers::toFileSize(1024 * 1024, 'ar'); // "١٫٠٠ ميجابايت"

// French formatting
echo ConvertNumbers::toFileSize(1024, 'fr'); // "1,00 Ko"
echo ConvertNumbers::toFileSize(1024 * 1024, 'fr'); // "1,00 Mo"

// Custom decimal places
echo ConvertNumbers::toFileSize(1234567, 'en', 3); // "1.177 MB"
```

Architecture
------------

[](#architecture)

The package follows SOLID principles and clean architecture:

1. **Single Responsibility Principle (SRP)**

    - Each class has a single responsibility
    - Language classes handle language-specific conversions
    - Currency classes manage currency-specific logic
    - Utility classes for formatting and conversion
2. **Open/Closed Principle (OCP)**

    - Easy to add new languages by extending `LanguageAbstract`
    - New currencies can be added by extending `CurrencyAbstract`
    - No modification needed to existing code
3. **Interface Segregation Principle (ISP)**

    - Separate interfaces for different functionalities
    - `ConverterInterface` for number conversion
    - `CurrencyInterface` for currency operations
    - `FileSizeInterface` for file size formatting
4. **Dependency Inversion Principle (DIP)**

    - High-level modules depend on abstractions
    - Easy to swap implementations

Features
--------

[](#features)

### 1. Number to Words Conversion

[](#1-number-to-words-conversion)

- Convert integers and decimal numbers to words
- Support for negative numbers
- Decimal point handling
- Language-specific formatting

### 2. Currency Handling

[](#2-currency-handling)

- Convert currency amounts to words
- Format currency with proper separators
- Optional currency symbol display
- Support for multiple currencies:
    - USD (US Dollar)
    - EUR (Euro)
    - EGP (Egyptian Pound)
    - SAR (Saudi Riyal)

### 3. File Size Formatting

[](#3-file-size-formatting)

- Convert bytes to human-readable formats
- Automatic unit selection (B, KB, MB, GB, TB, PB)
- Language-specific unit names
- Customizable decimal places

### 4. Multi-language Support

[](#4-multi-language-support)

- Arabic (ar)
- English (en)
- French (fr)

### 5. Number Formatting

[](#5-number-formatting)

- Language-specific decimal separators
- Thousands separators
- Arabic numeral conversion

Use Cases
---------

[](#use-cases)

Here are some practical scenarios where this package can be useful:

### 📄 Invoices &amp; Legal Documents

[](#-invoices--legal-documents)

- Convert numbers to words in invoices and contracts for better clarity.
- Display financial amounts in words to ensure legal accuracy.

### 💰 Financial &amp; Accounting Applications

[](#-financial--accounting-applications)

- Format and display monetary values properly.
- Convert currency values into readable words for multi-language support.

### 🛍 CMS &amp; E-commerce Platforms

[](#-cms--e-commerce-platforms)

- Improve user experience by displaying formatted numbers in different languages.
- Show file sizes in a human-readable format for media uploads.

### 🌍 Multi-language Applications

[](#-multi-language-applications)

- Convert numeric values to words in different languages without extra dependencies.
- Provide better localization for global users.

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

1. Fork the repository
2. Create your feature branch
3. Commit your changes
4. Push to the branch
5. Create a Pull Request

Change Log
----------

[](#change-log)

For a detailed list of changes and updates in each version, see the [Change Log](docs/CHANGELOG.md).

License
-------

[](#license)

This package is open-sourced software licensed under the [LICENSE](LICENSE) license.

Support
-------

[](#support)

For support:

- Email:
- Create an issue in the GitHub repository

Donations 💖
-----------

[](#donations-)

Maintaining this package takes time and effort. If you’d like to support its development and keep it growing, you can:

- 🌟 Star this repository
- 📢 Sharing it with others
- 🛠️ Contribute by reporting issues or suggesting features
- ☕ [Buy me a coffee](https://buymeacoffee.com/abdulbaset)
- ❤️ Become a sponsor on [GitHub Sponsors](https://github.com/sponsors/AbdulbasetRS)
- 💵 Make a one-time donation via [PayPal](https://paypal.me/abdulbasetrs)

Your support means a lot to me! Thank you for making this possible. 🙏

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance42

Moderate activity, may be stable

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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

Unknown

Total

1

Last Release

465d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1d770636a8684f5b3bb07c0871140986c12f0f9a225d97d3b5fca53a5d7bdca0?d=identicon)[AbdulBasetRS](/maintainers/AbdulBasetRS)

---

Top Contributors

[![AbdulbasetRS](https://avatars.githubusercontent.com/u/74756037?v=4)](https://github.com/AbdulbasetRS "AbdulbasetRS (4 commits)")

---

Tags

currency-converterPHP Librarymulti-languagearabic-numbersnumber to wordsnumber to textnumber conversionphp-packagenumbers-to-wordsenglish numberscurrency to wordswords convertercurrency formatter

### Embed Badge

![Health badge](/badges/abdulbaset-convert-numbers/health.svg)

```
[![Health](https://phpackages.com/badges/abdulbaset-convert-numbers/health.svg)](https://phpackages.com/packages/abdulbaset-convert-numbers)
```

###  Alternatives

[khaled.alshamaa/ar-php

Set of functionalities enable Arabic website developers to serve professional search, present and process Arabic content in PHP

3312.5M25](/packages/khaledalshamaa-ar-php)[lodash-php/lodash-php

A port of Lodash to PHP

527719.0k5](/packages/lodash-php-lodash-php)[riskihajar/terbilang

Number to words conversion support multi language.

134159.5k](/packages/riskihajar-terbilang)[yemenifree/laravel-arabic-numbers-middleware

auto transforms arabic/eastern to eastern/arabic numbers for i.e ١٢٣٤٥٦٧٨ to 12345678

18135.4k](/packages/yemenifree-laravel-arabic-numbers-middleware)[ujjwal/currency-converter

Currency Converter Class with features of caching and identifying currency from country Code

49225.4k](/packages/ujjwal-currency-converter)[niiknow/bayes

a machine learning lib

6950.0k](/packages/niiknow-bayes)

PHPackages © 2026

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