public function parseCommaSeparatedString($string, $maxLength = self::MAX_SEARCH_TERMS_LENGTH)
    {
        $result = null;

        // Check if string is not empty.
        if (strlen(trim($string)) === 0) {
            return null;
        }

        // Lower case for case insensitivity.
        $string = mb_strtolower($string, 'UTF-8');

        // Convert string to array.
        $fields = explode(',', $string);

        // Validate and trim each field.
        $fields = array_map([$this, 'trimAndValidateField'], $fields);

        // Remove null entries.
        $fields = array_filter($fields);

        // Parse back into string.
        $result = implode(',', $fields);

        // Check if max length is exceeded.
        if (strlen($result) > $maxLength) {
            // Shorten to max-length.
            $result = substr($result, 0, $maxLength);

            $fields = explode(',', $result);

            // Remove last element.
            array_pop($fields);

            // Only one search field is provided and exceeds limit.
            if (count($fields) === 0) {
                return null;
            }

            // Parse back into string.
            $result = implode(',', $fields);
        }

        return $result;
    }