1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
*/ |
4
|
|
|
|
5
|
|
|
namespace Commercetools\Core\Model\Common; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* @package Commercetools\Core\Model\Common |
9
|
|
|
* |
10
|
|
|
* @method string getCurrencyCode() |
11
|
|
|
* @method CentPrecisionMoney setCurrencyCode(string $currencyCode = null) |
12
|
|
|
* @method int getCentAmount() |
13
|
|
|
* @method CentPrecisionMoney setCentAmount(int $centAmount = null) |
14
|
|
|
* @method string getType() |
15
|
|
|
* @method CentPrecisionMoney setType(string $type = null) |
16
|
|
|
* @method string getFractionDigits() |
17
|
|
|
* @method CentPrecisionMoney setFractionDigits(string $fractionDigits = null) |
18
|
|
|
*/ |
19
|
|
|
class CentPrecisionMoney extends Money |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @inheritDoc |
23
|
|
|
*/ |
24
|
42 |
|
public function __construct(array $data = [], $context = null) |
25
|
|
|
{ |
26
|
42 |
|
$data[static::TYPE] = static::TYPE_CENT_PRECISION; |
27
|
42 |
|
parent::__construct($data, $context); |
28
|
42 |
|
} |
29
|
|
|
|
30
|
41 |
|
public function fieldDefinitions() |
31
|
|
|
{ |
32
|
|
|
return [ |
33
|
41 |
|
static::CURRENCY_CODE => [self::TYPE => 'string'], |
34
|
41 |
|
static::CENT_AMOUNT => [self::TYPE => 'int'], |
35
|
41 |
|
static::TYPE => [self::TYPE => 'string'], |
36
|
41 |
|
static::FRACTION_DIGITS => [self::TYPE => 'string'] |
37
|
|
|
]; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @param $currencyCode |
42
|
|
|
* @param $centAmount |
43
|
|
|
* @param Context|callable $context |
44
|
|
|
* @return Money |
45
|
|
|
*/ |
46
|
|
|
public static function ofCurrencyAndAmount($currencyCode, $centAmount, $context = null) |
47
|
|
|
{ |
48
|
|
|
$money = static::of($context); |
49
|
|
|
return $money->setCurrencyCode($currencyCode) |
50
|
|
|
->setCentAmount($centAmount); |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
|