1 <?php
2
3 namespace PayPal\Api;
4
5 use PayPal\Common\PayPalModel;
6 use PayPal\Converter\FormatConverter;
7 use PayPal\Validation\NumericValidator;
8
9 /**
10 * Class Currency
11 *
12 * Base object for all financial value related fields (balance, payment due, etc.)
13 *
14 * @package PayPal\Api
15 *
16 * @property string currency
17 * @property string value
18 */
19 class Currency extends PayPalModel
20 {
21 /**
22 * 3 letter currency code as defined by ISO 4217.
23 *
24 * @param string $currency
25 *
26 * @return $this
27 */
28 public function setCurrency($currency)
29 {
30 $this->currency = $currency;
31 return $this;
32 }
33
34 /**
35 * 3 letter currency code as defined by ISO 4217.
36 *
37 * @return string
38 */
39 public function getCurrency()
40 {
41 return $this->currency;
42 }
43
44 /**
45 * amount up to N digit after the decimals separator as defined in ISO 4217 for the appropriate currency code.
46 *
47 * @param string|double $value
48 *
49 * @return $this
50 */
51 public function setValue($value)
52 {
53 NumericValidator::validate($value, "Value");
54 $value = FormatConverter::formatToPrice($value, $this->getCurrency());
55 $this->value = $value;
56 return $this;
57 }
58
59 /**
60 * amount up to N digit after the decimals separator as defined in ISO 4217 for the appropriate currency code.
61 *
62 * @return string
63 */
64 public function getValue()
65 {
66 return $this->value;
67 }
68
69 }
70