Skip to content

Commit c9b3130

Browse files
authored
Add with ratio factory method to Rate (#12)
* Add Rate::withRatio * Remove old badges * Remove coveralls config * Fix CHANGELOG
1 parent 73aedf6 commit c9b3130

File tree

5 files changed

+47
-10
lines changed

5 files changed

+47
-10
lines changed

.coveralls.yml

-3
This file was deleted.

CHANGELOG.md

+26-1
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,36 @@ Security - in case of vulnerabilities.
1616

1717
## [Unreleased]
1818

19-
_TBD_
19+
### Changed
20+
21+
+ Migrated CI from **Travis CI** to **GitHub Actions**.
22+
+ Upgraded minimum PHP version to v7.3.
23+
24+
### Added
25+
26+
+ Added `Rate::withRatio` factory method to create modified value with specific ratio.
27+
+ Added static analyzer into CI flow.
28+
29+
## 1.0.3 (2019-12-05)
30+
31+
### Fixed
32+
33+
+ Reverted removal of deprecated currencies. See [#6](https://github.com/Rebilly/money/pull/6) for details.
34+
35+
### Added
36+
37+
+ Added a property to `Currency` showing that it is deprecated.
38+
39+
## 1.0.2 (2019-10-21)
40+
41+
### Changed
42+
43+
+ Updated currencies list: remove deprecated, added new, rename code of others. See [#5](https://github.com/Rebilly/money/pull/5) for details.
2044

2145
## 1.0.1 (2019-03-05)
2246

2347
### Fixed
48+
2449
+ Fixed pretty-print formatting of negative amount of money
2550

2651
## 1.0.0 (2018-12-08)

README.md

-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
[![Software License][ico-license]][link-license]
22
[![Latest Version on Packagist][ico-version]][link-packagist]
3-
[![Build Status][ico-travis]][link-travis]
4-
[![Coverage Status][ico-coveralls]][link-coveralls]
53
[![GitHub Actions status][ico-github-actions]][link-github]
64

75
# Money
@@ -248,11 +246,7 @@ The Money library is open-sourced under the [MIT License](./LICENSE) distributed
248246
[ico-github-actions]: https://github.com/Rebilly/money/workflows/Tests/badge.svg
249247
[ico-version]: https://img.shields.io/packagist/v/Rebilly/money.svg?style=flat-square
250248
[ico-license]: https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square
251-
[ico-travis]: https://img.shields.io/travis/Rebilly/money/master.svg?style=flat-square
252-
[ico-coveralls]: https://img.shields.io/coveralls/github/Rebilly/money.svg?style=flat-square
253249

254250
[link-github]: https://github.com/Rebilly/money
255251
[link-packagist]: https://packagist.org/packages/Rebilly/money
256252
[link-license]: LICENSE
257-
[link-travis]: https://travis-ci.org/Rebilly/money
258-
[link-coveralls]: https://coveralls.io/github/Rebilly/money?branch=master

src/Exchange/Rate.php

+5
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ public function convert(Money $money): Money
8181
return $money->convert($this->currencyPair->getQuoteCurrency(), $this->ratio, PHP_ROUND_HALF_UP);
8282
}
8383

84+
public function withRatio(float $ratio): self
85+
{
86+
return new self($this->getCurrencyPair(), $this->getDate(), $ratio);
87+
}
88+
8489
/**
8590
* {@inheritdoc}
8691
*/

tests/Exchange/RateTest.php

+16
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,22 @@ public function testCanBeConstructed()
3131
return $rate;
3232
}
3333

34+
/**
35+
* @depends testCanBeConstructed
36+
*/
37+
public function testCanBeRecreatedWithNewRatio(Rate $rate)
38+
{
39+
$ratio = $rate->getRatio() * 2;
40+
$mutatedRatio = $rate->withRatio($ratio);
41+
42+
self::assertNotSame($rate, $mutatedRatio);
43+
self::assertSame($rate->getCurrencyPair(), $mutatedRatio->getCurrencyPair());
44+
self::assertSame($rate->getDate(), $mutatedRatio->getDate());
45+
self::assertSame($ratio, $mutatedRatio->getRatio());
46+
47+
return $rate;
48+
}
49+
3450
/**
3551
* @depends testCanBeConstructed
3652
*

0 commit comments

Comments
 (0)