vendor/sylius/sylius/src/Sylius/Component/Currency/Model/Currency.php line 19

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Sylius package.
  4.  *
  5.  * (c) Paweł Jędrzejewski
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. declare(strict_types=1);
  11. namespace Sylius\Component\Currency\Model;
  12. use Sylius\Component\Resource\Model\TimestampableTrait;
  13. use Symfony\Component\Intl\Currencies;
  14. class Currency implements CurrencyInterface\Stringable
  15. {
  16.     use TimestampableTrait;
  17.     /** @var mixed */
  18.     protected $id;
  19.     /** @var string|null */
  20.     protected $code;
  21.     public function __construct()
  22.     {
  23.         $this->createdAt = new \DateTime();
  24.     }
  25.     public function __toString(): string
  26.     {
  27.         return (string) $this->getCode();
  28.     }
  29.     public function getId()
  30.     {
  31.         return $this->id;
  32.     }
  33.     public function getName(): ?string
  34.     {
  35.         if (null === $code $this->getCode()) {
  36.             return null;
  37.         }
  38.         return Currencies::getName($code);
  39.     }
  40.     public function getCode(): ?string
  41.     {
  42.         return $this->code;
  43.     }
  44.     public function setCode(?string $code): void
  45.     {
  46.         $this->code $code;
  47.     }
  48. }