<?phpnamespace App\Api\BrcBackend\DTO;use App\Api\BrcBackend\Enum\ProfileType;final class Profile implements ProfileInterface{ private int $id; private string $name; private string $slug; private City $city; private ?string $postalCode; private ?string $street; private ?string $nip; private ?string $email; private ?string $phone; private ?string $website; private bool $displayWebsite; private ?string $facebook; private ?string $instagram; private ?string $tiktok; private ?string $category; private ?string $businessIdentification; private ?string $scopeOfActivity; private ?string $reviewAnalysis; private ?string $mediaMentions; private ?string $socialMedia; private ?string $finalConclusion; private ?string $logo; private ?string $description; private ProfileType $type; private \DateTime $issueDate; private \DateTime $createdAt; private \DateTime $validityDate; private \DateTime $reportCreatedAt; private array $randomProfiles = []; private ?string $certificateImage; /** * @param array $profile * * @throws \Exception */ public function __construct(array $profile) { $this->id = $profile['id']; $this->name = $profile['name']; $this->slug = $profile['slug']; $this->city = new City($profile['city']['id'], $profile['city']['name'], $profile['city']['slug']); $this->postalCode = $profile['postalCode']; $this->street = $profile['street']; $this->nip = $profile['nip']; $this->email = $profile['email']; $this->phone = $profile['phone']; $this->website = $profile['website']; $this->displayWebsite = $profile['displayWebsite']; $this->facebook = $profile['facebook']; $this->instagram = $profile['instagram']; $this->tiktok = $profile['tiktok']; $this->category = $profile['category']; $this->businessIdentification = $profile['businessIdentification']; $this->scopeOfActivity = $profile['scopeOfActivity']; $this->reviewAnalysis = $profile['reviewAnalysis']; $this->mediaMentions = $profile['mediaMentions']; $this->socialMedia = $profile['socialMedia']; $this->finalConclusion = $profile['finalConclusion']; $this->logo = $profile['logo']; $this->description = $profile['description']; $this->type = ProfileType::get($profile['type']); $this->issueDate = new \DateTime($profile['issueDate']); $this->createdAt = new \DateTime($profile['createdAt']); $this->validityDate = new \DateTime($profile['validityDate']); $this->reportCreatedAt = new \DateTime($profile['reportCreatedAt']); $this->certificateImage = array_key_exists('certificate', $profile) ? $profile['certificate'] : null; foreach ($profile['randomProfiles'] as $randomProfile) { $this->randomProfiles[] = new RandomProfile($randomProfile); } } public function getId(): int { return $this->id; } public function getName(): string { return $this->name; } public function getSlug(): string { return $this->slug; } public function getCity(): City { return $this->city; } public function getCityAndPostalCode(): string { $city = ucfirst($this->city->getName()); return $this->postalCode ? sprintf('%s %s', $city, $this->postalCode) : $city; } public function getPostalCode(): ?string { return $this->postalCode; } public function getStreet(): ?string { return $this->street; } public function getNip(): ?string { return $this->nip; } public function getEmail(): ?string { return $this->email; } public function getPhone(): ?string { return $this->phone; } public function getWebsite(): ?string { return $this->website; } public function isDisplayWebsite(): bool { return $this->displayWebsite; } public function getFacebook(): ?string { return $this->facebook; } public function getInstagram(): ?string { return $this->instagram; } public function getTiktok(): ?string { return $this->tiktok; } public function getCategory(): ?string { return $this->category; } public function getBusinessIdentification(): ?string { return $this->businessIdentification; } public function getScopeOfActivity(): ?string { return $this->scopeOfActivity; } public function getReviewAnalysis(): ?string { return $this->reviewAnalysis; } public function getMediaMentions(): ?string { return $this->mediaMentions; } public function getSocialMedia(): ?string { return $this->socialMedia; } public function getFinalConclusion(): ?string { return $this->finalConclusion; } public function getLogo(): ?string { return $this->logo; } public function getDescription(): ?string { return $this->description; } public function getIssueDate(): \DateTime { return $this->issueDate; } public function getCreatedAt(): \DateTime { return $this->createdAt; } /** * @return array<RandomProfile> */ public function getRandomProfiles(): array { return $this->randomProfiles; } public function isExpired(): bool { return $this->validityDate < new \DateTime('now'); } public function getReportCreatedAt(): \DateTime { return $this->reportCreatedAt; } public function getValidityDate(): \DateTime { return $this->validityDate; } public function getType(): ProfileType { return $this->type; } public function getCertificateImage(): ?string { return $this->certificateImage; } public function setCertificateImage(?string $certificateImage): self { $this->certificateImage = $certificateImage; return $this; }}