-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
ee778e1
commit d8c6494
Showing
10 changed files
with
118 additions
and
98 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 @@ | ||
C:37:"PHPUnit\Runner\DefaultTestResultCache":596:{a:2:{s:7:"defects";a:2:{s:94:"RicorocksDigitalAgency\GiveAnInch\Tests\ExampleTest::it_calculates_the_distance_between_points";i:4;s:94:"RicorocksDigitalAgency\Giveaninch\Tests\ExampleTest::it_calculates_the_distance_between_points";i:3;}s:5:"times";a:3:{s:94:"RicorocksDigitalAgency\GiveAnInch\Tests\ExampleTest::it_calculates_the_distance_between_points";d:0.032;s:94:"RicorocksDigitalAgency\Giveaninch\Tests\ExampleTest::it_calculates_the_distance_between_points";d:0.041;s:103:"RicorocksDigitalAgency\Giveaninch\Tests\ExampleTest::it_can_say_if_something_is_within_a_certain_radius";d:0.037;}}} |
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
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,13 @@ | ||
<?php | ||
|
||
namespace RicorocksDigitalAgency\Giveaninch\Facades; | ||
|
||
use Illuminate\Support\Facades\Facade; | ||
|
||
class GiveAnInch extends Facade | ||
{ | ||
protected static function getFacadeAccessor() | ||
{ | ||
return 'giveaninch'; | ||
} | ||
} |
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,41 @@ | ||
<?php | ||
|
||
namespace RicorocksDigitalAgency\Giveaninch; | ||
|
||
class GiveAnInch | ||
{ | ||
protected $fromLat, $fromLng; | ||
protected $toLat, $toLng; | ||
|
||
public function from($lat, $lng) | ||
{ | ||
$this->fromLat = $lat; | ||
$this->fromLng = $lng; | ||
|
||
return $this; | ||
} | ||
|
||
public function to($lat, $lng) | ||
{ | ||
$this->toLat = $lat; | ||
$this->toLng = $lng; | ||
|
||
return $this; | ||
} | ||
|
||
public function getDistance() | ||
{ | ||
$ky = 40000 / 360; | ||
$kx = cos(pi() * $this->fromLat / 180.0) * $ky; | ||
$dy = abs($this->fromLat - $this->toLat) * $ky; | ||
$dx = abs($this->fromLng - $this->toLng) * $kx; | ||
|
||
return sqrt($dx * $dx + $dy * $dy); | ||
} | ||
|
||
public function isWithin(float $radius) | ||
{ | ||
return $this->getDistance() < $radius; | ||
} | ||
|
||
} |
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,32 @@ | ||
<?php | ||
|
||
namespace RicorocksDigitalAgency\Giveaninch; | ||
|
||
use Illuminate\Support\ServiceProvider; | ||
|
||
class GiveAnInchServiceProvider extends ServiceProvider | ||
{ | ||
/** | ||
* Bootstrap the application services. | ||
*/ | ||
public function boot() | ||
{ | ||
if ($this->app->runningInConsole()) { | ||
$this->publishes([ | ||
__DIR__.'/../config/config.php' => config_path('giveaninch.php'), | ||
], 'config'); | ||
} | ||
} | ||
|
||
/** | ||
* Register the application services. | ||
*/ | ||
public function register() | ||
{ | ||
$this->mergeConfigFrom(__DIR__.'/../config/config.php', 'giveaninch'); | ||
|
||
$this->app->bind('giveaninch', function () { | ||
return new GiveAnInch; | ||
}); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,12 @@ | ||
<?php | ||
|
||
|
||
namespace RicorocksDigitalAgency\Giveaninch; | ||
|
||
|
||
class Within | ||
{ | ||
public function __construct($fromLat, $fromLng, $toLat, $toLng) | ||
{ | ||
} | ||
} |
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