/*
 * Helper methods for trimming and formatting strings.
 *
 * Author: Harkamal
 * Date: April 2026
 */

package com.petshop.backend.util;

public final class StringUtils {

    private StringUtils() {}

    public static String trimToNull(String value) {
        if (value == null) {
            return null;
        }
        String trimmed = value.trim();
        return trimmed.isEmpty() ? null : trimmed;
    }

    public static String fullName(String firstName, String lastName) {
        String first = trimToNull(firstName);
        String last = trimToNull(lastName);
        if (first == null) {
            return last;
        }
        if (last == null) {
            return first;
        }
        return first + " " + last;
    }

    public static String normalizePhone(String value) {
        return trimToNull(PhoneUtils.normalize(trimToNull(value)));
    }
}
