src/Api/BrcBackend/DTO/Profile.php line 7

Open in your IDE?
  1. <?php
  2. namespace App\Api\BrcBackend\DTO;
  3. use App\Api\BrcBackend\Enum\ProfileType;
  4. final class Profile implements ProfileInterface
  5. {
  6.     private int $id;
  7.     private string $name;
  8.     private string $slug;
  9.     private City $city;
  10.     private ?string $postalCode;
  11.     private ?string $street;
  12.     private ?string $nip;
  13.     private ?string $email;
  14.     private ?string $phone;
  15.     private ?string $website;
  16.     private bool $displayWebsite;
  17.     private ?string $facebook;
  18.     private ?string $instagram;
  19.     private ?string $tiktok;
  20.     private ?string $category;
  21.     private ?string $businessIdentification;
  22.     private ?string $scopeOfActivity;
  23.     private ?string $reviewAnalysis;
  24.     private ?string $mediaMentions;
  25.     private ?string $socialMedia;
  26.     private ?string $finalConclusion;
  27.     private ?string $logo;
  28.     private ?string $description;
  29.     private ProfileType $type;
  30.     private \DateTime $issueDate;
  31.     private \DateTime $createdAt;
  32.     private \DateTime $validityDate;
  33.     private \DateTime $reportCreatedAt;
  34.     private array $randomProfiles = [];
  35.     private ?string $certificateImage;
  36.     /**
  37.      * @param array $profile
  38.      *
  39.      * @throws \Exception
  40.      */
  41.     public function __construct(array $profile)
  42.     {
  43.         $this->id $profile['id'];
  44.         $this->name $profile['name'];
  45.         $this->slug $profile['slug'];
  46.         $this->city = new City($profile['city']['id'], $profile['city']['name'], $profile['city']['slug']);
  47.         $this->postalCode $profile['postalCode'];
  48.         $this->street $profile['street'];
  49.         $this->nip $profile['nip'];
  50.         $this->email $profile['email'];
  51.         $this->phone $profile['phone'];
  52.         $this->website $profile['website'];
  53.         $this->displayWebsite $profile['displayWebsite'];
  54.         $this->facebook $profile['facebook'];
  55.         $this->instagram $profile['instagram'];
  56.         $this->tiktok $profile['tiktok'];
  57.         $this->category $profile['category'];
  58.         $this->businessIdentification $profile['businessIdentification'];
  59.         $this->scopeOfActivity $profile['scopeOfActivity'];
  60.         $this->reviewAnalysis $profile['reviewAnalysis'];
  61.         $this->mediaMentions $profile['mediaMentions'];
  62.         $this->socialMedia $profile['socialMedia'];
  63.         $this->finalConclusion $profile['finalConclusion'];
  64.         $this->logo $profile['logo'];
  65.         $this->description $profile['description'];
  66.         $this->type ProfileType::get($profile['type']);
  67.         $this->issueDate = new \DateTime($profile['issueDate']);
  68.         $this->createdAt = new \DateTime($profile['createdAt']);
  69.         $this->validityDate = new \DateTime($profile['validityDate']);
  70.         $this->reportCreatedAt = new \DateTime($profile['reportCreatedAt']);
  71.         $this->certificateImage array_key_exists('certificate'$profile) ? $profile['certificate'] : null;
  72.         foreach ($profile['randomProfiles'] as $randomProfile) {
  73.             $this->randomProfiles[] = new RandomProfile($randomProfile);
  74.         }
  75.     }
  76.     public function getId(): int
  77.     {
  78.         return $this->id;
  79.     }
  80.     public function getName(): string
  81.     {
  82.         return $this->name;
  83.     }
  84.     public function getSlug(): string
  85.     {
  86.         return $this->slug;
  87.     }
  88.     public function getCity(): City
  89.     {
  90.         return $this->city;
  91.     }
  92.     public function getCityAndPostalCode(): string
  93.     {
  94.         $city ucfirst($this->city->getName());
  95.         return $this->postalCode
  96.             sprintf('%s %s'$city$this->postalCode)
  97.             : $city;
  98.     }
  99.     public function getPostalCode(): ?string
  100.     {
  101.         return $this->postalCode;
  102.     }
  103.     public function getStreet(): ?string
  104.     {
  105.         return $this->street;
  106.     }
  107.     public function getNip(): ?string
  108.     {
  109.         return $this->nip;
  110.     }
  111.     public function getEmail(): ?string
  112.     {
  113.         return $this->email;
  114.     }
  115.     public function getPhone(): ?string
  116.     {
  117.         return $this->phone;
  118.     }
  119.     public function getWebsite(): ?string
  120.     {
  121.         return $this->website;
  122.     }
  123.     public function isDisplayWebsite(): bool
  124.     {
  125.         return $this->displayWebsite;
  126.     }
  127.     public function getFacebook(): ?string
  128.     {
  129.         return $this->facebook;
  130.     }
  131.     public function getInstagram(): ?string
  132.     {
  133.         return $this->instagram;
  134.     }
  135.     public function getTiktok(): ?string
  136.     {
  137.         return $this->tiktok;
  138.     }
  139.     public function getCategory(): ?string
  140.     {
  141.         return $this->category;
  142.     }
  143.     public function getBusinessIdentification(): ?string
  144.     {
  145.         return $this->businessIdentification;
  146.     }
  147.     public function getScopeOfActivity(): ?string
  148.     {
  149.         return $this->scopeOfActivity;
  150.     }
  151.     public function getReviewAnalysis(): ?string
  152.     {
  153.         return $this->reviewAnalysis;
  154.     }
  155.     public function getMediaMentions(): ?string
  156.     {
  157.         return $this->mediaMentions;
  158.     }
  159.     public function getSocialMedia(): ?string
  160.     {
  161.         return $this->socialMedia;
  162.     }
  163.     public function getFinalConclusion(): ?string
  164.     {
  165.         return $this->finalConclusion;
  166.     }
  167.     public function getLogo(): ?string
  168.     {
  169.         return $this->logo;
  170.     }
  171.     public function getDescription(): ?string
  172.     {
  173.         return $this->description;
  174.     }
  175.     public function getIssueDate(): \DateTime
  176.     {
  177.         return $this->issueDate;
  178.     }
  179.     public function getCreatedAt(): \DateTime
  180.     {
  181.         return $this->createdAt;
  182.     }
  183.     /**
  184.      * @return array<RandomProfile>
  185.      */
  186.     public function getRandomProfiles(): array
  187.     {
  188.         return $this->randomProfiles;
  189.     }
  190.     public function isExpired(): bool
  191.     {
  192.         return $this->validityDate < new \DateTime('now');
  193.     }
  194.     public function getReportCreatedAt(): \DateTime
  195.     {
  196.         return $this->reportCreatedAt;
  197.     }
  198.     public function getValidityDate(): \DateTime
  199.     {
  200.         return $this->validityDate;
  201.     }
  202.     public function getType(): ProfileType
  203.     {
  204.         return $this->type;
  205.     }
  206.     public function getCertificateImage(): ?string
  207.     {
  208.         return $this->certificateImage;
  209.     }
  210.     public function setCertificateImage(?string $certificateImage): self
  211.     {
  212.         $this->certificateImage $certificateImage;
  213.         return $this;
  214.     }
  215. }