for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Asti\Weather;
class LocationService
{
/*
*
* curls api, get_file_contents
* sends response to model
*/
private $key = null;
private $url = null;
public function setKey($key)
$this->key = $key;
}
public function setUrl($url): void
$this->url = $url;
public function getKey(): string
return $this->key;
public function getUrl(): string
return $this->url;
public function curlIpApi($ipAdr): array
$curl = new CurlService();
if ($ipAdr!= "") {
$res = $curl->getDataThroughCurl($this->getUrl() . $ipAdr . "?access_key=" . $this->getKey());
if ($res["type"] == null) {
$json = [
"Message" => "IP-adressen är fel. Försök igen!"
];
return $json;
"Type" => $res["type"],
"Valid" => $res["type"] ? "ipv4" || "ipv6" : "not valid",
"UserInput" => $res["ip"],
"Latitude" => $res["latitude"],
"Longitude" => $res["longitude"],
"City" => $res["city"],
"Country" => $res["country_name"],
return [$json];
else {
"Message" => "IP-adressen är tom. Försök igen"