PHPackages                             harp-orm/money - 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. harp-orm/money

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

harp-orm/money
==============

Helper Traits for Sebastian Bergmann's Money

0.2.2(11y ago)01821BSD-3-ClausePHPPHP &gt;=5.4.0

Since Jun 26Pushed 11y ago1 watchersCompare

[ Source](https://github.com/harp-orm/money)[ Packagist](https://packagist.org/packages/harp-orm/money)[ RSS](/packages/harp-orm-money/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (4)Dependencies (2)Versions (5)Used By (1)

Money
=====

[](#money)

[![Build Status](https://camo.githubusercontent.com/a3274f271f7a8a6d4dde097266434371f949eec043bb21a779f58cde40be30e6/68747470733a2f2f7472617669732d63692e6f72672f686172702d6f726d2f6d6f6e65792e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/harp-orm/money)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/1ff82303e8d6ae83d221682f3b3f6dcfab288aaf9699988891f528b7d3254328/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f686172702d6f726d2f6d6f6e65792f6261646765732f7175616c6974792d73636f72652e706e67)](https://scrutinizer-ci.com/g/harp-orm/money/)[![Code Coverage](https://camo.githubusercontent.com/6edcaf44753c045fa8fe9c5efa3045d1db5c767278afaa026509359784bf3886/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f686172702d6f726d2f6d6f6e65792f6261646765732f636f7665726167652e706e67)](https://scrutinizer-ci.com/g/harp-orm/money/)[![Latest Stable Version](https://camo.githubusercontent.com/4daacc0552c75a5ade4defa0f74855d53c298db9ffe9a8c7c1b688a25190bbeb/68747470733a2f2f706f7365722e707567782e6f72672f686172702d6f726d2f6d6f6e65792f762f737461626c652e706e67)](https://packagist.org/packages/harp-orm/money)

Helper Traits for Sebastian Bergmann's Money

Usage
-----

[](#usage)

This adds "value" properties to your models, using traits. This is accomplished with ValueTrait and CurrencyTrait. The first adds the methods responsible for working with the Money objects, while CurencyTrait handles keeping tabs on which currency to use.

```
// Model Class
use Harp\Harp\AbstractModel;
use Harp\Money\ValueTrait;
use Harp\Money\CurrencyTrait;

class User extends AbstractModel
{
    use ValueTrait;
    use CurrencyTrait;

    public static function initialize($config)
    {
        // ...
        ValueTrait::initialize($config)
        CurrencyTrait::initialize($config)
    }
    // ...
}

```

**Database Table:**

```
┌─────────────────────────┐
│ Table: User             │
├─────────────┬───────────┤
│ id          │ ingeter   │
│ name        │ string    │
│ currency*   │ string    │
│ value*      │ integer   │
└─────────────┴───────────┘
* Required fields

```

Methods
-------

[](#methods)

**ValueTrait Methods**

MethodDescription**getValue**()Return a new Money object that represents the value property in the model, using the currency object returned from a "getCurrency" method.**setValue**(Money $money)Set the parent model**CurrencyTrait Methods**

MethodDescription**getCurrency**()Return a new Currency object, based on the currency property in the modelFreezable
---------

[](#freezable)

Using the FreezableTrait will allow you to easily freeze values in the database. You will need to implement performFreeze and performUnfreeze methods. **Database Table:**

```
┌─────────────────────────┐
│ Table: User             │
├─────────────┬───────────┤
│ id          │ ingeter   │
│ name        │ string    │
│ isFrozen*   │ integer   │
└─────────────┴───────────┘
* Required fields

```

**FreezableTrait Methods**

MethodDescription**freeze**()call the `performFreeze` method if the model is not "frozen", e.g. isFrozen property is false. And set isFrozen to true after `performFreeze` is called**unfreeze**()call the `performUnfreeze` method if the model is "frozen", e.g. isFrozen property is true. And set isFrozen to false after `performUnfreeze` is calledFreezable Value
---------------

[](#freezable-value)

This combines ValueTrait and FreezableTrait to allow you to "freeze" values in the model. It requires a `getSourceValue` which returns the dynamic value as a Money object. After "freeze" is called the result of `getSourceValue` is stored in the database, and subsequent calls to "getValue" will return the frozen value.

Additionally if the price from `getSourceValue` is with a different currency, use Converter class to convert the to the target currency.

**FreezableTrait Methods**

MethodDescription**freeze**()From FreezableTrait**unfreeze**()From FreezableTrait**setValue**()From ValueTrait**getValue**(Money $money)From ValueTrait**getConvertedSourceValue**()return a Money object from getSourceValue converted to a proper currency with**performFreeze**()implements a FreezableTrait requirement, saves the value**performUnfreeze**()implements a FreezableTrait requirement, clears the value frozen in the databaseLicense
-------

[](#license)

Copyright (c) 2014, Clippings Ltd. Developed by Ivan Kerin

Under BSD-3-Clause license, read LICENSE file.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity51

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

Every ~20 days

Total

4

Last Release

4280d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/506129?v=4)[Harry Dobrev](/maintainers/hkdobrev)[@hkdobrev](https://github.com/hkdobrev)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/harp-orm-money/health.svg)

```
[![Health](https://phpackages.com/badges/harp-orm-money/health.svg)](https://phpackages.com/packages/harp-orm-money)
```

###  Alternatives

[dsposito/argo

A shipping utility.

23177.0k](/packages/dsposito-argo)

PHPackages © 2026

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