Skip to content
This repository was archived by the owner on Sep 18, 2024. It is now read-only.

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
Traineratwot authored and github-actions[bot] committed Jan 18, 2024
1 parent 0811c86 commit fddda51
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions src/Forms/Components/MapInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ protected function setUp(): void
$value = $component->parseInput($state);
switch ($component->saveAs) {
case 'Point':
return (new Point($value['latitude'], $value['longitude']));
return new Point($value['latitude'], $value['longitude']);
break;
case 'Array':
return ([$value['latitude'], $value['longitude']]);
return [$value['latitude'], $value['longitude']];
break;
case 'String':
default:
return ("{$value['latitude']},{$value['longitude']}");
return "{$value['latitude']},{$value['longitude']}";
break;
}
});
Expand All @@ -64,22 +64,24 @@ protected function setUp(): void
*/
protected float|int|Closure $longitude = 0;


public function saveAsPoint(): static
{
$this->saveAs = 'Point';

return $this;
}

public function saveAsString(): static
{
$this->saveAs = 'String';

return $this;
}

public function saveAsArray(): static
{
$this->saveAs = 'Array';

return $this;
}

Expand All @@ -99,27 +101,30 @@ protected function parseInput(mixed $state): array
if (count($_state) !== 2) {
throw new Exception("Invalid state: $state ");
}

return [
'latitude' => (float)$_state[0],
'longitude' => (float)$_state[1],
'latitude' => (float) $_state[0],
'longitude' => (float) $_state[1],
];
}

if (is_array($state)) {
if(isset($state['type']) && $state['type'] === 'Point') {
if (isset($state['type']) && $state['type'] === 'Point') {
return [
'latitude' => $state['coordinates'][1],
'longitude' => $state['coordinates'][0],
];
}
if (count($state) !== 2) {
throw new Exception("Invalid state: " . json_encode($state));
throw new Exception('Invalid state: '.json_encode($state));
}

return [
'latitude' => (float)$state[0],
'longitude' => (float)$state[1],
'latitude' => (float) $state[0],
'longitude' => (float) $state[1],
];
}

return [
'latitude' => $this->latitude,
'longitude' => $this->longitude,
Expand Down Expand Up @@ -151,12 +156,14 @@ public function coordinates(float|int|Closure $latitude, float|int|Closure $long
public function getLatitude(): ?float
{
$a = $this->parseInput($this->getState());

return $a['latitude'] ?: $this->evaluate($this->latitude) ?: 0;
}

public function getLongitude(): ?float
{
$a = $this->parseInput($this->getState());

return $a['longitude'] ?: $this->evaluate($this->longitude) ?: 0;
}
}

0 comments on commit fddda51

Please sign in to comment.