Cmfcmf\OpenWeatherMap::buildQueryUrlParameter PHP Method

buildQueryUrlParameter() private method

Builds the query string for the url.
private buildQueryUrlParameter ( mixed $query ) : string
$query mixed
return string The built query string for the url.
    private function buildQueryUrlParameter($query)
    {
        switch ($query) {
            case is_array($query) && isset($query['lat']) && isset($query['lon']) && is_numeric($query['lat']) && is_numeric($query['lon']):
                return "lat={$query['lat']}&lon={$query['lon']}";
            case is_array($query) && is_numeric($query[0]):
                return 'id=' . implode(',', $query);
            case is_numeric($query):
                return "id={$query}";
            case is_string($query):
                return 'q=' . urlencode($query);
            default:
                throw new \InvalidArgumentException('Error: $query has the wrong format. See the documentation of OpenWeatherMap::getWeather() to read about valid formats.');
        }
    }