2017 © Pedro Peláez
 

library euro

Value object for representing a positive amount of Euro

image

wmde/euro

Value object for representing a positive amount of Euro

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 7 Versions
  • 10 % Grown

The README.md

Euro

Build Status Scrutinizer Code Quality Code Coverage Latest Stable Version Download count, (*1)

Value Object that represents a positive amount of Euro., (*2)

Installation

To add this package as a local, per-project dependency to your project, simply add a dependency on wmde/euro to your project's composer.json file. Here is a minimal example of a composer.json file that just defines a dependency on Euro 1.x:, (*3)

{
    "require": {
        "wmde/euro": "^1.0.1"
    }
}

Usage

Construction

Constructing from Euro cents (int):, (*4)

$productPrice = Euro::newFromCents(4200);

Constructing from a Euro amount (float):, (*5)

$productPrice = Euro::newFromFloat(42.00);

Constructing from a Euro amount (string):, (*6)

$productPrice = Euro::newFromString('42.00');

Constructing from a Euro amount (int):, (*7)

$productPrice = Euro::newFromInt(42);

Access

echo $productPrice->getEuroCents();
// 4200 (int) for all above examples
echo $productPrice->getEuroFloat();
// 42.0 (float) for all above examples
echo $productPrice->getEuroString();
// "42.00" (string) for all above examples

Comparison

Euro::newFromCents(4200)->equals(Euro::newFromInt(42));
// true
Euro::newFromCents(4201)->equals(Euro::newFromInt(42));
// false

Running the tests

For tests only, (*8)

composer test

For style checks only, (*9)

composer cs

For a full CI run, (*10)

composer ci

Release notes

1.1.1 (dev)

  • Large numbers now cause an InvalidArgumentException rather than a TypeError

1.1.0 (2018-03-21)

  • Bumped minimum PHP version from 7.0 to 7.1

1.0.2 (2018-03-20)

  • Internal changes to avoid dealing with floats when constructing an Euro object from string

1.0.1 (2018-03-17)

  • Fixed rounding issue occurring on some platforms

1.0.0 (2016-07-31)

  • Initial release

The Versions

21/03 2018

dev-master

9999999-dev https://github.com/wmde/Euro

Value object for representing a positive amount of Euro

  Sources   Download

GPL-2.0+ GPL-2.0-or-later

The Requires

  • php >=7.1

 

The Development Requires

21/03 2018

1.1.0

1.1.0.0 https://github.com/wmde/Euro

Value object for representing a positive amount of Euro

  Sources   Download

GPL-2.0-or-later

The Requires

  • php >=7.1

 

The Development Requires

20/03 2018

dev-php71

dev-php71 https://github.com/wmde/Euro

Value object for representing a positive amount of Euro

  Sources   Download

GPL-2.0-or-later

The Requires

  • php >=7.1

 

The Development Requires

20/03 2018

dev-avoid-float

dev-avoid-float https://github.com/wmde/Euro

Value object for representing a positive amount of Euro

  Sources   Download

GPL-2.0-or-later

The Requires

  • php >=7.0

 

The Development Requires

19/03 2018

1.0.1

1.0.1.0 https://github.com/wmde/Euro

Value object for representing a positive amount of Euro

  Sources   Download

GPL-2.0-or-later

The Requires

  • php >=7.0

 

The Development Requires

17/03 2018

dev-rel101

dev-rel101 https://github.com/wmde/Euro

Value object for representing a positive amount of Euro

  Sources   Download

GPL-2.0-or-later

The Requires

  • php >=7.0

 

The Development Requires

31/07 2016

1.0.0

1.0.0.0 https://github.com/wmde/Euro

Value object for representing a positive amount of Euro

  Sources   Download

GPL-2.0+

The Requires

  • php >=7.0

 

The Development Requires