| Total Complexity | 7 |
| Total Lines | 75 |
| Duplicated Lines | 0 % |
| Coverage | 89.47% |
| Changes | 0 | ||
| 1 | <?php |
||
| 24 | class Amount { |
||
| 25 | /** |
||
| 26 | * Currency. |
||
| 27 | * |
||
| 28 | * @var string |
||
| 29 | */ |
||
| 30 | private $currency; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * Value. |
||
| 34 | * |
||
| 35 | * @var int |
||
| 36 | */ |
||
| 37 | private $value; |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Construct amount. |
||
| 41 | * |
||
| 42 | * @param string $currency Currency. |
||
| 43 | * @param int $value Value. |
||
| 44 | */ |
||
| 45 | 4 | public function __construct( $currency, $value ) { |
|
| 46 | 4 | $this->currency = $currency; |
|
| 47 | 4 | $this->value = $value; |
|
| 48 | 4 | } |
|
| 49 | |||
| 50 | /** |
||
| 51 | * Get currency. |
||
| 52 | * |
||
| 53 | * @return string |
||
| 54 | */ |
||
| 55 | 2 | public function get_currency() { |
|
| 56 | 2 | return $this->currency; |
|
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * Get amount. |
||
| 61 | * |
||
| 62 | * @return int |
||
| 63 | */ |
||
| 64 | 2 | public function get_value() { |
|
| 65 | 2 | return $this->value; |
|
| 66 | } |
||
| 67 | |||
| 68 | /** |
||
| 69 | * Get JSON. |
||
| 70 | * |
||
| 71 | * @return object |
||
| 72 | */ |
||
| 73 | 1 | public function get_json() { |
|
| 74 | return (object) array( |
||
| 75 | 1 | 'currency' => $this->get_currency(), |
|
| 76 | 1 | 'value' => $this->get_value(), |
|
| 77 | ); |
||
| 78 | } |
||
| 79 | |||
| 80 | /** |
||
| 81 | * Create amount from object. |
||
| 82 | * |
||
| 83 | * @param object $object Object. |
||
| 84 | * @return Amount |
||
| 85 | * @throws InvalidArgumentException Throws invalid argument exception when object does not contains the required properties. |
||
| 86 | */ |
||
| 87 | 2 | public static function from_object( $object ) { |
|
| 99 | ); |
||
| 100 | } |
||
| 101 | } |
||
| 102 |