1 | <?php namespace Arcanedev\Currencies\Entities; |
||
12 | class RateCollection extends Collection |
||
13 | { |
||
14 | /* ------------------------------------------------------------------------------------------------ |
||
15 | | Properties |
||
16 | | ------------------------------------------------------------------------------------------------ |
||
17 | */ |
||
18 | /** |
||
19 | * The `from` currency iso. |
||
20 | * |
||
21 | * @var string |
||
22 | */ |
||
23 | protected $from; |
||
24 | |||
25 | /* ------------------------------------------------------------------------------------------------ |
||
26 | | Getters & Setters |
||
27 | | ------------------------------------------------------------------------------------------------ |
||
28 | */ |
||
29 | /** |
||
30 | * Get the `from` currency iso. |
||
31 | * |
||
32 | * @return string |
||
33 | */ |
||
34 | 24 | public function getFrom() |
|
38 | |||
39 | /** |
||
40 | * Set the `from` currency iso. |
||
41 | * |
||
42 | * @param string $from |
||
43 | * |
||
44 | * @return self |
||
45 | */ |
||
46 | 24 | protected function setFrom($from) |
|
47 | { |
||
48 | 24 | $this->from = $from; |
|
49 | |||
50 | 24 | return $this; |
|
51 | } |
||
52 | |||
53 | /* ------------------------------------------------------------------------------------------------ |
||
54 | | Main Functions |
||
55 | | ------------------------------------------------------------------------------------------------ |
||
56 | */ |
||
57 | /** |
||
58 | * Load rates. |
||
59 | * |
||
60 | * @param string $from |
||
61 | * @param array $rates |
||
62 | * |
||
63 | * @return self |
||
64 | */ |
||
65 | 24 | public function load($from, array $rates) |
|
76 | |||
77 | /** |
||
78 | * Add a rate to the collection. |
||
79 | * |
||
80 | * @param string $to |
||
81 | * @param double|int $ratio |
||
82 | * |
||
83 | * @return self |
||
84 | */ |
||
85 | 24 | public function add($to, $ratio) |
|
91 | |||
92 | /** |
||
93 | * Add a Rate object to the collection. |
||
94 | * |
||
95 | * @param \Arcanedev\Currencies\Contracts\Entities\Rate $rate |
||
96 | * |
||
97 | * @return self |
||
98 | */ |
||
99 | 24 | public function addRate(RateContract $rate) |
|
105 | |||
106 | /** |
||
107 | * Get a rate by `to` iso. |
||
108 | * |
||
109 | * @param string $key |
||
110 | * @param null $default |
||
111 | * |
||
112 | * @return \Arcanedev\Currencies\Entities\Rate |
||
113 | */ |
||
114 | 24 | public function get($key, $default = null) |
|
118 | } |
||
119 |