Open-source event management and ticket selling platform — perfect for concerts, conferences, and everything in between 🎟️ If you find this project helpful, please consider giving us a star ⭐️
PHP attendize-alternativedoor-managementevent-check-inevent-managementevent-registrationevent-ticketingeventbrite-alternativeeventslaravelopen-sourcephpreactself-hostedsell-ticketssell-tickets-onlineticket-sellingticketing-systemtickettailor-alternativetito-alternative
<?php
namespace HiEvents\Services\Domain\Question;
use HiEvents\DomainObjects\Enums\QuestionTypeEnum;
class QuestionAnswerFormatter
{
public function getAnswerAsText(string|array $answer, QuestionTypeEnum $questionType): string
{
if ($questionType === QuestionTypeEnum::ADDRESS) {
$addressLines = [
$answer['address_line_1'] ?? null,
$answer['address_line_2'] ?? null,
$answer['city'] ?? null,
$answer['state_or_region'] ?? null,
$answer['zip_or_postal_code'] ?? null,
$answer['country'] ?? null,
];
return implode(', ', array_filter($addressLines, static function ($line) {
return ! empty($line);
}));
}
if (is_array($answer)) {
return implode(', ', $answer);
}
return $answer;
}
}