src/Platform/SecurityBundle/Entity/Profiles/SystemProfile.php line 15

Open in your IDE?
  1. <?php
  2. namespace Platform\SecurityBundle\Entity\Profiles;
  3. use Doctrine\ORM\Mapping as ORM;
  4. /**
  5.  * Various things needed for an account at the system level.
  6.  *
  7.  * Class SystemProfile
  8.  * @package Platform\SecurityBundle\Entity\Profiles
  9.  *
  10.  * @ORM\Embeddable
  11.  */
  12. class SystemProfile
  13. {
  14.     /**
  15.      * Name to display for the user.
  16.      * If none given, their email and/or account ID would be used in place of this.
  17.      *
  18.      * @var string|null
  19.      *
  20.      * @ORM\Column(
  21.      *     type = "string",
  22.      *     nullable = true,
  23.      * )
  24.      */
  25.     protected ?string $displayName null;
  26.     /**
  27.      *
  28.      * @var string|null
  29.      *
  30.      * @ORM\Column(
  31.      *     type = "string",
  32.      *     nullable = true,
  33.      * )
  34.      */
  35.     protected ?string $firstName null;
  36.     /**
  37.      *
  38.      * @var string|null
  39.      *
  40.      * @ORM\Column(
  41.      *     type = "string",
  42.      *     nullable = true,
  43.      * )
  44.      */
  45.     protected ?string $lastName null;
  46.     /**
  47.      * Whether this person has an avatar uploaded.
  48.      *
  49.      * @var bool
  50.      *
  51.      * @ORM\Column(
  52.      *     type = "boolean",
  53.      *     nullable = true,
  54.      * )
  55.      */
  56.     protected ?bool $avatar false;
  57.     /**
  58.      * Mobile phone for notification testing.
  59.      *
  60.      * @var string|null
  61.      *
  62.      * @ORM\Column(
  63.      *     type = "string",
  64.      *     nullable = true,
  65.      * )
  66.      */
  67.     protected ?string $mobilePhone null;
  68.     /**
  69.      * @return bool
  70.      */
  71.     public function hasAvatar(): bool
  72.     {
  73.         return ($this->avatar === true);
  74.     }
  75.     /**
  76.      * @param bool $value
  77.      * @return $this
  78.      */
  79.     public function setAvatar(bool $value): self
  80.     {
  81.         $this->avatar = ($value === true);
  82.         return $this;
  83.     }
  84.     /**
  85.      * @return string|null
  86.      */
  87.     public function getDisplayName(): ?string
  88.     {
  89.         return $this->displayName;
  90.     }
  91.     /**
  92.      * @param string|null $displayName
  93.      * @return $this
  94.      */
  95.     public function setDisplayName(?string $displayName): self
  96.     {
  97.         $this->displayName $displayName ?: null;
  98.         return $this;
  99.     }
  100.     /**
  101.      * @return string|null
  102.      */
  103.     public function getMobilePhone(): ?string
  104.     {
  105.         return $this->mobilePhone;
  106.     }
  107.     /**
  108.      * @param string|null $mobilePhone
  109.      * @return $this
  110.      */
  111.     public function setMobilePhone(?string $mobilePhone): self
  112.     {
  113.         $this->mobilePhone $mobilePhone ?: null;
  114.         return $this;
  115.     }
  116.     /**
  117.      * @return string
  118.      */
  119.     public function getFirstName(): ?string
  120.     {
  121.         return $this->firstName;
  122.     }
  123.     /**
  124.      * @param string|null $firstName
  125.      * @return $this
  126.      */
  127.     public function setFirstName(?string $firstName): self
  128.     {
  129.         $this->firstName $firstName ?: null;
  130.         return $this;
  131.     }
  132.     /**
  133.      * @return string|null
  134.      */
  135.     public function getLastName(): ?string
  136.     {
  137.         return $this->lastName;
  138.     }
  139.     /**
  140.      * @param string|null $lastName
  141.      * @return $this
  142.      */
  143.     public function setLastName(?string $lastName): self
  144.     {
  145.         $this->lastName $lastName ?: null;
  146.         return $this;
  147.     }
  148.     /**
  149.      * @return string|null
  150.      */
  151.     public function getFullName(): ?string
  152.     {
  153.         if ($this->getFirstName() || $this->getLastName()) {
  154.             return trim(sprintf(
  155.                 '%s %s',
  156.                 $this->getFirstName(),
  157.                 $this->getLastName(),
  158.             )) ?: null;
  159.         }
  160.         return null;
  161.     }
  162. }