mirror of
https://github.com/shlinkio/shlink.git
synced 2024-12-22 23:23:42 -06:00
Changed latitude and longitude to float
This commit is contained in:
parent
0cf1d8d375
commit
0e04968bc2
@ -11,10 +11,10 @@
|
||||
"type": "string"
|
||||
},
|
||||
"latitude": {
|
||||
"type": "string"
|
||||
"type": "number"
|
||||
},
|
||||
"longitude": {
|
||||
"type": "string"
|
||||
"type": "number"
|
||||
},
|
||||
"regionName": {
|
||||
"type": "string"
|
||||
|
@ -105,8 +105,8 @@
|
||||
"cityName": "Cupertino",
|
||||
"countryCode": "US",
|
||||
"countryName": "United States",
|
||||
"latitude": "37.3042",
|
||||
"longitude": "-122.0946",
|
||||
"latitude": 37.3042,
|
||||
"longitude": -122.0946,
|
||||
"regionName": "California",
|
||||
"timezone": "America/Los_Angeles"
|
||||
}
|
||||
|
@ -14,8 +14,8 @@ class VisitLocation extends AbstractEntity implements VisitLocationInterface
|
||||
private string $countryName;
|
||||
private string $regionName;
|
||||
private string $cityName;
|
||||
private string $latitude; // FIXME Should be float
|
||||
private string $longitude; // FIXME Should be float
|
||||
private float $latitude;
|
||||
private float $longitude;
|
||||
private string $timezone;
|
||||
|
||||
public function __construct(Location $location)
|
||||
@ -25,22 +25,22 @@ class VisitLocation extends AbstractEntity implements VisitLocationInterface
|
||||
|
||||
public function getCountryName(): string
|
||||
{
|
||||
return $this->countryName ?? '';
|
||||
return $this->countryName;
|
||||
}
|
||||
|
||||
public function getLatitude(): string
|
||||
public function getLatitude(): float
|
||||
{
|
||||
return $this->latitude ?? '';
|
||||
return $this->latitude;
|
||||
}
|
||||
|
||||
public function getLongitude(): string
|
||||
public function getLongitude(): float
|
||||
{
|
||||
return $this->longitude ?? '';
|
||||
return $this->longitude;
|
||||
}
|
||||
|
||||
public function getCityName(): string
|
||||
{
|
||||
return $this->cityName ?? '';
|
||||
return $this->cityName;
|
||||
}
|
||||
|
||||
private function exchangeLocationInfo(Location $info): void
|
||||
@ -49,8 +49,8 @@ class VisitLocation extends AbstractEntity implements VisitLocationInterface
|
||||
$this->countryName = $info->countryName();
|
||||
$this->regionName = $info->regionName();
|
||||
$this->cityName = $info->city();
|
||||
$this->latitude = (string) $info->latitude();
|
||||
$this->longitude = (string) $info->longitude();
|
||||
$this->latitude = $info->latitude();
|
||||
$this->longitude = $info->longitude();
|
||||
$this->timezone = $info->timeZone();
|
||||
}
|
||||
|
||||
@ -74,8 +74,8 @@ class VisitLocation extends AbstractEntity implements VisitLocationInterface
|
||||
$this->countryName === '' &&
|
||||
$this->regionName === '' &&
|
||||
$this->cityName === '' &&
|
||||
((float) $this->latitude) === 0.0 &&
|
||||
((float) $this->longitude) === 0.0 &&
|
||||
$this->latitude === 0.0 &&
|
||||
$this->longitude === 0.0 &&
|
||||
$this->timezone === '';
|
||||
}
|
||||
}
|
||||
|
@ -11,14 +11,14 @@ final class UnknownVisitLocation implements VisitLocationInterface
|
||||
return 'Unknown';
|
||||
}
|
||||
|
||||
public function getLatitude(): string
|
||||
public function getLatitude(): float
|
||||
{
|
||||
return '0.0';
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
public function getLongitude(): string
|
||||
public function getLongitude(): float
|
||||
{
|
||||
return '0.0';
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
public function getCityName(): string
|
||||
@ -33,8 +33,8 @@ final class UnknownVisitLocation implements VisitLocationInterface
|
||||
'countryName' => 'Unknown',
|
||||
'regionName' => 'Unknown',
|
||||
'cityName' => 'Unknown',
|
||||
'latitude' => '0.0',
|
||||
'longitude' => '0.0',
|
||||
'latitude' => 0.0,
|
||||
'longitude' => 0.0,
|
||||
'timezone' => 'Unknown',
|
||||
];
|
||||
}
|
||||
|
@ -10,9 +10,9 @@ interface VisitLocationInterface extends JsonSerializable
|
||||
{
|
||||
public function getCountryName(): string;
|
||||
|
||||
public function getLatitude(): string;
|
||||
public function getLatitude(): float;
|
||||
|
||||
public function getLongitude(): string;
|
||||
public function getLongitude(): float;
|
||||
|
||||
public function getCityName(): string;
|
||||
}
|
||||
|
@ -10,16 +10,6 @@ use Shlinkio\Shlink\IpGeolocation\Model\Location;
|
||||
|
||||
class VisitLocationTest extends TestCase
|
||||
{
|
||||
/** @test */
|
||||
public function valuesFoundWhenExchangingArrayAreCastToString(): void
|
||||
{
|
||||
$payload = new Location('', '', '', '', 1000.7, -2000.4, '');
|
||||
$location = new VisitLocation($payload);
|
||||
|
||||
$this->assertSame('1000.7', $location->getLatitude());
|
||||
$this->assertSame('-2000.4', $location->getLongitude());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @dataProvider provideArgs
|
||||
|
Loading…
Reference in New Issue
Block a user