public static function splitRecipient($recipient, $countryCode)
    {
        // Countries that write the family name before the given name.
        $reverseCountries = [
            'KH', 'CN', 'HU', 'JP', 'KO', 'MG', 'TW', 'VN',
        ];
        $recipientParts = explode(' ', $recipient);
        if (in_array($countryCode, $reverseCountries)) {
            $familyName = array_shift($recipientParts);
            $givenName = implode(' ', $recipientParts);
        } else {
            $familyName = array_pop($recipientParts);
            $givenName = implode(' ', $recipientParts);
        }

        return ['givenName' => $givenName, 'familyName' => $familyName];
    }
public static function splitRecipient($recipient, $countryCode)
    {
        // Countries that write the family name before the given name.
        $reverseCountries = [
            'KH', 'CN', 'HU', 'JP', 'KO', 'MG', 'TW', 'VN',
        ];
        $recipientParts = explode(' ', $recipient);
        if (in_array($countryCode, $reverseCountries)) {
            $familyName = array_shift($recipientParts);
            $givenName = implode(' ', $recipientParts);
        } else {
            $familyName = array_pop($recipientParts);
            $givenName = implode(' ', $recipientParts);
        }

        return ['givenName' => $givenName, 'familyName' => $familyName];
    }
public static function splitRecipient ( $ recipient , $ countryCode ) { // Countries that write the family name before the given name. $ reverseCountries = [ 'KH' , 'CN' , 'HU' , 'JP' , 'KO' , 'MG' , 'TW' , 'VN' , ] ; $ recipientParts = explode ( ' ' , $ recipient ) ; if ( in_array ( $ countryCode , $ reverseCountries ) ) { $ familyName = array_shift ( $ recipientParts ) ; $ givenName = implode ( ' ' , $ recipientParts ) ; } else { $ familyName = array_pop ( $ recipientParts ) ; $ givenName = implode ( ' ' , $ recipientParts ) ; } return [ 'givenName' => $ givenName , 'familyName' => $ familyName ] ; }
Splits the recipient into givenName and familyName fields.

@param string $recipient   The recipient.
@param string $countryCode The country code.

@return array The result, with givenName and familyName keys.
Splits the recipient into givenName and familyName fields .