bytic /
money
| 1 | <?php |
||
| 2 | |||
| 3 | namespace ByTIC\Money\Models\Currencies; |
||
| 4 | |||
| 5 | /** |
||
| 6 | * trait CurrenciesTrait. |
||
| 7 | * |
||
| 8 | * @method CurrencyTrait[] getAll() |
||
| 9 | * @method CurrencyTrait findByCode($code) |
||
| 10 | */ |
||
| 11 | trait CurrenciesTrait |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * @param $from |
||
| 15 | * @param $to |
||
| 16 | * @param $amount |
||
| 17 | * |
||
| 18 | * @return float|int |
||
| 19 | */ |
||
| 20 | public function convert($from, $to, $amount) |
||
| 21 | { |
||
| 22 | $rates['eur'] = '1'; |
||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
Loading history...
|
|||
| 23 | $rates['bgn'] = '0.5113'; |
||
| 24 | $rates['ron'] = '0.2260'; |
||
| 25 | |||
| 26 | return $amount * $rates[$from] / $rates[$to]; |
||
| 27 | } |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @param $code |
||
| 31 | * |
||
| 32 | * @return CurrencyTrait |
||
| 33 | */ |
||
| 34 | public function getByCode($code) |
||
| 35 | { |
||
| 36 | return $this->findOne($code); |
||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @param $id |
||
| 41 | * |
||
| 42 | * @return CurrencyTrait |
||
| 43 | */ |
||
| 44 | abstract public function findOne($id); |
||
| 45 | } |
||
| 46 |