PHPackages                             nethask/currency - 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. nethask/currency

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

nethask/currency
================

Currency conversion and formatting

1.0.0(9y ago)0591proprietaryPHPPHP &gt;=5.3.0

Since Jul 1Pushed 9y ago1 watchersCompare

[ Source](https://github.com/nethask/currency)[ Packagist](https://packagist.org/packages/nethask/currency)[ RSS](/packages/nethask-currency/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (3)Versions (2)Used By (1)

Currency Package
================

[](#currency-package)

fork of

The Moltin currency composer package makes it easy to implement multi-currency pricing into your application and store the exchange data using one of the numerous data stores provided. You can also inject your own data store if you would like your data to be stored elsewhere.

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

[](#installation)

Download and install composer from `http://www.getcomposer.org/download`

Add the following to your project `composer.json` file

```
{
    "require": {
        "moltin/currency": "1.0.*@dev"
    }
}

```

When you're done just run `php composer.phar install` and the package is ready to be used.

Usage
-----

[](#usage)

Below is a basic usage guide for this package.

### Instantiating currency

[](#instantiating-currency)

Before you begin, you will need to know which storage, currencies and exchange method you are going to use. The exchange method defines where your exchange rates are retrieved from. The currencies method is used to retrieve your supported currencies for the current application.

In this example we're going to use the currencies file, exchange file and session for storage.

```
use Moltin\Currency\Currency as Currency;
use Moltin\Currency\Format\Runtime as RuntimeFormat;
use Moltin\Currency\Exchange\OpenExchangeRates as OpenExchange;

$currency = new Currency(new OpenExchange($app_id), new RuntimeFormat);
```

### Setting the value

[](#setting-the-value)

Now that you have Currency instantiated, you will now need to tell it what value you would like to convert. You can do this using the following method.

```
$currency->convert(9.33)->from('GBP');
```

### Getting the value

[](#getting-the-value)

The most basic action you can perform is retrieve the original value back from the method.

```
// Returns 9.33
$value = $currency->value();
```

### Formatting as a currency

[](#formatting-as-a-currency)

By default the currency is set to GBP so calling currency will format the value to a string with £ and correct decimal and thousand seperators.

```
// Returns £9.33
$value = $currency->format();
```

### Rounding to common values

[](#rounding-to-common-values)

There are a number of common pricing formats built in to make "nice" prices easy to implement. These formats changes the default value and return the object to allow for chaining.

```
// Sets value to 10.00
$currency->zeros();

// Sets value to 9.99
$currency->nines();

// Sets value to 9.50
$currency->fifty();

// Returns £9.50
$value = $currency->fifty()->format();
```

### Currency Exchange

[](#currency-exchange)

The package makes it as easy as possible to quickly switch between currencies. Before each exchange the value is reset to default to ensure the correct price is assigned.

```
// Returns ~$14.47
$value = $currency->convert(9.33)->from('GBP')->to('USD')->format();

// Returns ~14.50
$value = $currency->convert(9.33)->from('GBP')->to('USD')->fifty()->value();
```

### Resetting the value

[](#resetting-the-value)

After using exchange or any of the rounding functions to retrieve the default value you must call reset.

```
// Returns 10.00
$value = $currency->zeros()->value();

// Returns 9.33
$value = $currency->reset()->value();
```

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 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

3286d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4312591?v=4)[Artyom Knyazev](/maintainers/nethask)[@nethask](https://github.com/nethask)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/nethask-currency/health.svg)

```
[![Health](https://phpackages.com/badges/nethask-currency/health.svg)](https://phpackages.com/packages/nethask-currency)
```

###  Alternatives

[krizon/php-ga-measurement-protocol

Easy use of the Google Analytics Measurement Protocol in PHP

108587.4k5](/packages/krizon-php-ga-measurement-protocol)[amplifier/yii-amqp

AMQP adapter for Yii

2237.2k](/packages/amplifier-yii-amqp)[baidubce/bce-sdk-php

BCE SDK for PHP

142.6k2](/packages/baidubce-bce-sdk-php)

PHPackages © 2026

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