-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace JeroenG\Explorer\Domain\Syntax; | ||
|
||
use JeroenG\Explorer\Domain\Syntax\SyntaxInterface; | ||
|
||
|
||
class GeoDistance implements SyntaxInterface | ||
{ | ||
|
||
public const DISTANCE_TYPE_ARC = 'arc'; | ||
public const DISTANCE_TYPE_PLANE = 'palne'; | ||
public const DEFAULT_FIELD = 'location'; | ||
|
||
private int $distance; | ||
private mixed $lat; | ||
private mixed $lng; | ||
private ?string $distance_type; | ||
private string $field; | ||
|
||
public function __construct( | ||
$distance, | ||
$lat, | ||
$lng, | ||
$distance_type = self::DISTANCE_TYPE_ARC, | ||
$field = self::DEFAULT_FIELD, | ||
) { | ||
$this->distance = $distance; | ||
$this->lat = $lat; | ||
$this->lng = $lng; | ||
$this->field = $field; | ||
$this->distance_type = $distance_type; | ||
} | ||
|
||
public function build(): array | ||
{ | ||
return [ | ||
'geo_distance' => [ | ||
'distance' => (string) $this->distance, | ||
'distance_type' => (string) $this->distance_type, | ||
$this->field => [ | ||
'lat' => (string) $this->lat, | ||
'lon' => (string) $this->lng | ||
] | ||
] | ||
]; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters