<?php

declare(strict_types=1);

namespace App\Service\Core;

use App\Entity\Core\AddressPostal;

class AddressPostalUtils
{
    /**
     * Concatenate the three streetAddress parts of the given address.
     */
    public function getFullStreetAddress(AddressPostal $addressPostal, string $separator = "\n"): string
    {
        return implode($separator, array_filter([
            trim($addressPostal->getStreetAddress() ?? ''),
            trim($addressPostal->getStreetAddressSecond() ?? ''),
            trim($addressPostal->getStreetAddressThird() ?? ''),
        ], static function ($addressPart) { return !empty($addressPart); })
        );
    }
}
