<?php

namespace App\Service\Core;

use App\Entity\Core\AddressPostal;

class AddressPostalUtils
{
    /**
     * Concatenate the three streetAddress parts of the given address
     *
     * @param AddressPostal $addressPostal
     * @param string $separator
     * @return string
     */
    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); })
        );
    }
}
