WC_Shipping::get_default_method PHP Method

get_default_method() private method

Get the default method.
private get_default_method ( array $available_methods, boolean $current_chosen_method = false ) : string
$available_methods array
$current_chosen_method boolean
return string
    private function get_default_method($available_methods, $current_chosen_method = false)
    {
        if (!empty($available_methods)) {
            if (!empty($current_chosen_method)) {
                if (isset($available_methods[$current_chosen_method])) {
                    return $available_methods[$current_chosen_method]->id;
                } else {
                    foreach ($available_methods as $method_key => $method) {
                        if (strpos($method->id, $current_chosen_method) === 0) {
                            return $method->id;
                        }
                    }
                }
            }
            return current($available_methods)->id;
        }
        return '';
    }