vendor/sylius/sylius/src/Sylius/Component/Locale/Model/Locale.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\Locale\Model;
  12. use Sylius\Component\Resource\Model\TimestampableTrait;
  13. use Symfony\Component\Intl\Locales;
  14. class Locale implements LocaleInterface\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->getName();
  28.     }
  29.     public function getId()
  30.     {
  31.         return $this->id;
  32.     }
  33.     public function getCode(): ?string
  34.     {
  35.         return $this->code;
  36.     }
  37.     public function setCode(?string $code): void
  38.     {
  39.         $this->code $code;
  40.     }
  41.     public function getName(?string $locale null): ?string
  42.     {
  43.         return Locales::getName($this->getCode(), $locale);
  44.     }
  45. }