Compare commits
7 Commits
0.0.7
...
issue/34-g
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cb16158eb3 | ||
|
|
58d0e93fc9 | ||
|
|
5c87bf35d5 | ||
|
|
84ba22f287 | ||
|
|
eaa1c0a173 | ||
|
|
af13393765 | ||
|
|
7e0c231d88 |
@@ -1,4 +1,4 @@
|
||||
FROM php:8.1-alpine
|
||||
FROM php:8.3-alpine
|
||||
|
||||
WORKDIR /code
|
||||
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
|
||||
|
||||
8
LICENSE
8
LICENSE
@@ -1 +1,7 @@
|
||||
License
|
||||
Copyright (c) 2024 PCM
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
@@ -14,17 +14,17 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^8.1.0",
|
||||
"symfony/http-client": "^6.1",
|
||||
"symfony/dependency-injection": "^6.1",
|
||||
"symfony/framework-bundle": "^6.1",
|
||||
"symfony/yaml": "^6.1",
|
||||
"php": "^8.3.0",
|
||||
"symfony/http-client": "^7.1",
|
||||
"symfony/dependency-injection": "^7.1",
|
||||
"symfony/framework-bundle": "^7.1",
|
||||
"symfony/yaml": "^7.1",
|
||||
"doctrine/orm": "^2.13"
|
||||
},
|
||||
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^9.5",
|
||||
"symfony/phpunit-bridge": "^6.1"
|
||||
"symfony/phpunit-bridge": "^7.1"
|
||||
},
|
||||
|
||||
"autoload": {
|
||||
|
||||
@@ -23,3 +23,4 @@ class LatLongModel
|
||||
return $this->longitude;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ use Symfony\Contracts\HttpClient\ResponseInterface;
|
||||
|
||||
class Geocoder
|
||||
{
|
||||
private const API_URL = "https://nominatim.openstreetmap.org/search";
|
||||
private const string API_URL = "https://nominatim.openstreetmap.org/search";
|
||||
|
||||
public function __construct(private HttpClientInterface $client) {}
|
||||
|
||||
@@ -30,6 +30,10 @@ class Geocoder
|
||||
return null;
|
||||
}
|
||||
|
||||
if (array_key_exists('error', $data)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->createLatLongModel($data);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,12 +12,12 @@ use Pcm\GeocodeBundle\Tests\AppKernel;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
|
||||
/**
|
||||
* Note we sleep 1s after requests to prevent breaking the API T&Cs
|
||||
* We sleep 1 second after API calls to prevent breaking the API T&Cs.
|
||||
*/
|
||||
class GeocodeTest extends KernelTestCase
|
||||
{
|
||||
// Buckingham Palace
|
||||
private const POSTCODE = 'SW1A 1AA';
|
||||
private const string POSTCODE = 'SW1A 1AA';
|
||||
|
||||
private Geocoder $geocoder;
|
||||
|
||||
@@ -54,3 +54,4 @@ class GeocodeTest extends KernelTestCase
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ use PHPUnit\Framework\TestCase;
|
||||
|
||||
class MappableTraitTest extends TestCase
|
||||
{
|
||||
private const FLOAT = 123.456;
|
||||
private const float COORD = 123.456;
|
||||
|
||||
private MappableInterface $obj;
|
||||
|
||||
@@ -21,7 +21,7 @@ class MappableTraitTest extends TestCase
|
||||
|
||||
public function testSetLatitude(): void
|
||||
{
|
||||
$this->assertInstanceOf(MappableInterface::class, $this->obj->setLatitude(self::FLOAT));
|
||||
$this->assertInstanceOf(MappableInterface::class, $this->obj->setLatitude(self::COORD));
|
||||
}
|
||||
|
||||
public function testGetLatitudeReturnsNull(): void
|
||||
@@ -31,13 +31,13 @@ class MappableTraitTest extends TestCase
|
||||
|
||||
public function testGetLatitude(): void
|
||||
{
|
||||
$this->obj->setLatitude(self::FLOAT);
|
||||
$this->assertSame(self::FLOAT, $this->obj->getLatitude());
|
||||
$this->obj->setLatitude(self::COORD);
|
||||
$this->assertSame(self::COORD, $this->obj->getLatitude());
|
||||
}
|
||||
|
||||
public function testSetLongitude(): void
|
||||
{
|
||||
$this->assertInstanceOf(MappableInterface::class, $this->obj->setLongitude(self::FLOAT));
|
||||
$this->assertInstanceOf(MappableInterface::class, $this->obj->setLongitude(self::COORD));
|
||||
}
|
||||
|
||||
public function testGetLongitudeReturnsNull(): void
|
||||
@@ -47,8 +47,8 @@ class MappableTraitTest extends TestCase
|
||||
|
||||
public function testGetLongitude(): void
|
||||
{
|
||||
$this->obj->setLongitude(self::FLOAT);
|
||||
$this->assertSame(self::FLOAT, $this->obj->getLongitude());
|
||||
$this->obj->setLongitude(self::COORD);
|
||||
$this->assertSame(self::COORD, $this->obj->getLongitude());
|
||||
}
|
||||
|
||||
public function testIsGeocodedReturnsFalse(): void
|
||||
@@ -58,20 +58,20 @@ class MappableTraitTest extends TestCase
|
||||
|
||||
public function testIsGeocodedReturnsFalseIfLatIsSet(): void
|
||||
{
|
||||
$this->obj->setLatitude(self::FLOAT);
|
||||
$this->obj->setLatitude(self::COORD);
|
||||
$this->assertFalse($this->obj->isGeocoded());
|
||||
}
|
||||
|
||||
public function testIsGeocodedReturnsFalseIfLonIsSet(): void
|
||||
{
|
||||
$this->obj->setLongitude(self::FLOAT);
|
||||
$this->obj->setLongitude(self::COORD);
|
||||
$this->assertFalse($this->obj->isGeocoded());
|
||||
}
|
||||
|
||||
public function testIsGeocodedReturnsTrueIfLatAndLonAreSet(): void
|
||||
{
|
||||
$this->obj->setLatitude(self::FLOAT);
|
||||
$this->obj->setLongitude(self::FLOAT);
|
||||
$this->obj->setLatitude(self::COORD);
|
||||
$this->obj->setLongitude(self::COORD);
|
||||
$this->assertTrue($this->obj->isGeocoded());
|
||||
}
|
||||
|
||||
@@ -89,5 +89,5 @@ class MappableTraitTest extends TestCase
|
||||
use MappableTrait;
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user