vendor/sylius/customer/Model/Customer.php line 18

  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\Customer\Model;
  12. use Sylius\Component\Resource\Model\TimestampableTrait;
  13. class Customer implements CustomerInterface\Stringable
  14. {
  15.     use TimestampableTrait;
  16.     /** @var mixed */
  17.     protected $id;
  18.     /** @var string|null */
  19.     protected $email;
  20.     /** @var string|null */
  21.     protected $emailCanonical;
  22.     /** @var string|null */
  23.     protected $firstName;
  24.     /** @var string|null */
  25.     protected $lastName;
  26.     /** @var \DateTimeInterface|null */
  27.     protected $birthday;
  28.     /** @var string */
  29.     protected $gender CustomerInterface::UNKNOWN_GENDER;
  30.     /** @var CustomerGroupInterface|null */
  31.     protected $group;
  32.     /** @var string|null */
  33.     protected $phoneNumber;
  34.     /** @var bool */
  35.     protected $subscribedToNewsletter false;
  36.     public function __construct()
  37.     {
  38.         $this->createdAt = new \DateTime();
  39.     }
  40.     public function __toString(): string
  41.     {
  42.         return (string) $this->getEmail();
  43.     }
  44.     public function getId()
  45.     {
  46.         return $this->id;
  47.     }
  48.     public function getEmail(): ?string
  49.     {
  50.         return $this->email;
  51.     }
  52.     public function setEmail(?string $email): void
  53.     {
  54.         $this->email $email;
  55.     }
  56.     public function getEmailCanonical(): ?string
  57.     {
  58.         return $this->emailCanonical;
  59.     }
  60.     public function setEmailCanonical(?string $emailCanonical): void
  61.     {
  62.         $this->emailCanonical $emailCanonical;
  63.     }
  64.     public function getFullName(): string
  65.     {
  66.         return trim(sprintf('%s %s'$this->firstName$this->lastName));
  67.     }
  68.     public function getFirstName(): ?string
  69.     {
  70.         return $this->firstName;
  71.     }
  72.     public function setFirstName(?string $firstName): void
  73.     {
  74.         $this->firstName $firstName;
  75.     }
  76.     public function getLastName(): ?string
  77.     {
  78.         return $this->lastName;
  79.     }
  80.     public function setLastName(?string $lastName): void
  81.     {
  82.         $this->lastName $lastName;
  83.     }
  84.     public function getBirthday(): ?\DateTimeInterface
  85.     {
  86.         return $this->birthday;
  87.     }
  88.     public function setBirthday(?\DateTimeInterface $birthday): void
  89.     {
  90.         $this->birthday $birthday;
  91.     }
  92.     public function getGender(): string
  93.     {
  94.         return $this->gender;
  95.     }
  96.     public function setGender(?string $gender): void
  97.     {
  98.         $this->gender $gender;
  99.     }
  100.     public function isMale(): bool
  101.     {
  102.         return CustomerInterface::MALE_GENDER === $this->gender;
  103.     }
  104.     public function isFemale(): bool
  105.     {
  106.         return CustomerInterface::FEMALE_GENDER === $this->gender;
  107.     }
  108.     public function getGroup(): ?CustomerGroupInterface
  109.     {
  110.         return $this->group;
  111.     }
  112.     public function setGroup(?CustomerGroupInterface $group): void
  113.     {
  114.         $this->group $group;
  115.     }
  116.     public function getPhoneNumber(): ?string
  117.     {
  118.         return $this->phoneNumber;
  119.     }
  120.     public function setPhoneNumber(?string $phoneNumber): void
  121.     {
  122.         $this->phoneNumber $phoneNumber;
  123.     }
  124.     public function isSubscribedToNewsletter(): bool
  125.     {
  126.         return $this->subscribedToNewsletter;
  127.     }
  128.     public function setSubscribedToNewsletter(bool $subscribedToNewsletter): void
  129.     {
  130.         $this->subscribedToNewsletter $subscribedToNewsletter;
  131.     }
  132. }