Open Monograph Press  3.3.0
vendor/moneyphp/money/src/Currency.php
1 <?php
2 
3 namespace Money;
4 
14 final class Currency implements \JsonSerializable
15 {
21  private $code;
22 
26  public function __construct($code)
27  {
28  if (!is_string($code)) {
29  throw new \InvalidArgumentException('Currency code should be string');
30  }
31 
32  if ($code === '') {
33  throw new \InvalidArgumentException('Currency code should not be empty string');
34  }
35 
36  $this->code = $code;
37  }
38 
44  public function getCode()
45  {
46  return $this->code;
47  }
48 
56  public function equals(Currency $other)
57  {
58  return $this->code === $other->code;
59  }
60 
68  public function isAvailableWithin(Currencies $currencies)
69  {
70  return $currencies->contains($this);
71  }
72 
76  public function __toString()
77  {
78  return $this->code;
79  }
80 
86  public function jsonSerialize()
87  {
88  return $this->code;
89  }
90 }
Money\Currency\jsonSerialize
jsonSerialize()
Definition: vendor/moneyphp/money/src/Currency.php:89
Money
Money\Currency\equals
equals(Currency $other)
Definition: vendor/moneyphp/money/src/Currency.php:59
DataObject\__construct
__construct()
Definition: DataObject.inc.php:58
Money\Currency
Definition: vendor/moneyphp/money/src/Currency.php:14
Money\Currency\getCode
getCode()
Definition: vendor/moneyphp/money/src/Currency.php:47
Money\Currency\__construct
__construct($code)
Definition: vendor/moneyphp/money/src/Currency.php:29
Money\Currency\isAvailableWithin
isAvailableWithin(Currencies $currencies)
Definition: vendor/moneyphp/money/src/Currency.php:71
Money\Currencies
Definition: Currencies.php:12
Money\Currency\__toString
__toString()
Definition: vendor/moneyphp/money/src/Currency.php:79