Skip to content

Commit

Permalink
Added docs
Browse files Browse the repository at this point in the history
  • Loading branch information
JeroenDeDauw committed Apr 1, 2017
1 parent 6253729 commit eff7a88
Showing 1 changed file with 86 additions and 0 deletions.
86 changes: 86 additions & 0 deletions README.md
Expand Up @@ -8,6 +8,92 @@

[Value Object](https://en.wikipedia.org/wiki/Value_object) that represents a positive amount of Euro.

## 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:

```json
{
"require": {
"wmde/euro": "~1.0"
}
}
```

## Usage

### Construction

Constructing from Euro cents (int):

```php
$productPrice = Euro::newFromCents(4200);
```

Constructing from a Euro amount (float):

```php
$productPrice = Euro::newFromFloat(42.00);
```

Constructing from a Euro amount (string):

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

Constructing from a Euro amount (int):

```php
$productPrice = Euro::newFromInt(42);
```

### Access

```php
echo $productPrice->getEuroCents();
// 4200 (int) for all above examples
```

```php
echo $productPrice->getEuroFloat();
// 42.0 (float) for all above examples
```

```php
echo $productPrice->getEuroString();
// "42.00" (string) for all above examples
```

### Comparison

```php
Euro::newFromCents(4200)->equals(Euro::newFromInt(42));
// true
```

```php
Euro::newFromCents(4201)->equals(Euro::newFromInt(42));
// false
```

## Running the tests

For tests only

composer test

For style checks only

composer cs

For a full CI run

composer ci

## Release notes

### 1.0.0 (2016-07-31)
Expand Down

0 comments on commit eff7a88

Please sign in to comment.