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

Commit 98f9b19

Browse files
authored
Merge pull request #129 from mstaack/rework-tests
cleanup and namespaces
2 parents 9c417da + d065660 commit 98f9b19

36 files changed

+215
-304
lines changed

.github/workflows/run-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Test Suite
22

3-
on: [push, pull_request]
3+
on: [push]
44

55
jobs:
66
tests:

README.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,36 @@
1-
Laravel postgis extension
2-
=========================
1+
Laravel Wrapper for PostgreSQL's Geo-Extension Postgis
2+
======================================================
33

44
![Build Status](https://github.com/mstaack/laravel-postgis/workflows/Test%20Suite/badge.svg)
55

66
## Features
77

8-
* Work with geometry classes instead of arrays. (`$myModel->myPoint = new Point(1,2)`)
9-
* Adds helpers in migrations. (`$table->polygon('myColumn')`)
8+
* Work with geometry classes instead of arrays.
9+
```php
10+
$model->myPoint = new Point(1,2); //lat, long
11+
```
12+
13+
* Adds helpers in migrations.
14+
```php
15+
$table->polygon('myColumn');
16+
```
1017

1118
## Versions
1219
- Use 4.* for Laravel 5
1320
- Use 5.* for Laravel 6/7
1421

1522
## Warning
1623
This Package has been moved to a new owner and aims for Laravel 6/7 and PHP 7 support only soon!
24+
25+
Replace all your references to the new namespace: `MStaack\LaravelPostgis`
26+
1727
Thanks to :
1828
- https://github.com/njbarrett
1929
- https://github.com/phaza
2030
- https://github.com/mirzap
2131

32+
Fluent in Laravel Packages and Postgres/Postgis? Consider contributing! We are looking for anyone that wants to help out!
33+
2234
## Installation
2335

2436
```bash

composer.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@
1919
}
2020
},
2121
"autoload-dev": {
22-
"classmap": [
23-
"tests/BaseTestCase.php",
24-
"tests/Stubs/"
25-
]
22+
"psr-4": {
23+
"MStaack\\LaravelPostgis\\Tests\\": "tests/"
24+
}
2625
},
2726
"license": "MIT",
2827
"authors": [

config/postgis.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22

33
return [
4-
5-
'schema' => 'public' // Schema for the Postgis extension
6-
7-
];
4+
'schema' => 'public' // Schema for the Postgis extension
5+
];

src/DatabaseServiceProvider.php

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1-
<?php namespace MStaack\LaravelPostgis;
1+
<?php
22

3+
namespace MStaack\LaravelPostgis;
4+
5+
use Bosnadev\Database\DatabaseServiceProvider as PostgresDatabaseServiceProvider;
36
use Illuminate\Database\DatabaseManager;
47
use MStaack\LaravelPostgis\Connectors\ConnectionFactory;
5-
use Bosnadev\Database\DatabaseServiceProvider as PostgresDatabaseServiceProvider;
68

7-
/**
8-
* Class DatabaseServiceProvider
9-
* @package MStaack\LaravelPostgis
10-
*/
119
class DatabaseServiceProvider extends PostgresDatabaseServiceProvider
1210
{
13-
public function boot() {
14-
// Load the config
15-
$config_path = __DIR__ . '/../config/postgis.php';
16-
$this->publishes([$config_path => config_path('postgis.php')], 'postgis');
17-
$this->mergeConfigFrom($config_path, 'postgis');
11+
public function boot()
12+
{
13+
// Load the config
14+
$config_path = __DIR__ . '/../config/postgis.php';
15+
$this->publishes([$config_path => config_path('postgis.php')], 'postgis');
16+
$this->mergeConfigFrom($config_path, 'postgis');
1817
}
1918

2019
/**

src/Geometries/Factory.php

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,46 @@
1-
<?php namespace MStaack\LaravelPostgis\Geometries;
1+
<?php
22

3-
class Factory implements \GeoIO\Factory {
4-
public function createPoint( $dimension, array $coordinates, $srid = null )
3+
namespace MStaack\LaravelPostgis\Geometries;
4+
5+
class Factory implements \GeoIO\Factory
6+
{
7+
public function createPoint($dimension, array $coordinates, $srid = null)
58
{
6-
return new Point( $coordinates['y'], $coordinates['x'], isset($coordinates['z']) ? $coordinates['z'] : null );
9+
return new Point($coordinates['y'], $coordinates['x'], $coordinates['z'] ?? null);
710
}
811

9-
public function createLineString( $dimension, array $points, $srid = null )
12+
public function createLineString($dimension, array $points, $srid = null)
1013
{
11-
return new LineString( $points );
14+
return new LineString($points);
1215
}
1316

14-
public function createLinearRing( $dimension, array $points, $srid = null )
17+
public function createLinearRing($dimension, array $points, $srid = null)
1518
{
16-
return new LineString( $points );
19+
return new LineString($points);
1720
}
1821

19-
public function createPolygon( $dimension, array $lineStrings, $srid = null )
22+
public function createPolygon($dimension, array $lineStrings, $srid = null)
2023
{
21-
return new Polygon( $lineStrings );
24+
return new Polygon($lineStrings);
2225
}
2326

24-
public function createMultiPoint( $dimension, array $points, $srid = null )
27+
public function createMultiPoint($dimension, array $points, $srid = null)
2528
{
26-
return new MultiPoint( $points );
29+
return new MultiPoint($points);
2730
}
2831

29-
public function createMultiLineString( $dimension, array $lineStrings, $srid = null )
32+
public function createMultiLineString($dimension, array $lineStrings, $srid = null)
3033
{
31-
return new MultiLineString( $lineStrings );
34+
return new MultiLineString($lineStrings);
3235
}
3336

34-
public function createMultiPolygon( $dimension, array $polygons, $srid = null )
37+
public function createMultiPolygon($dimension, array $polygons, $srid = null)
3538
{
36-
return new MultiPolygon( $polygons );
39+
return new MultiPolygon($polygons);
3740
}
3841

39-
public function createGeometryCollection( $dimension, array $geometries, $srid = null )
42+
public function createGeometryCollection($dimension, array $geometries, $srid = null)
4043
{
41-
return new GeometryCollection( $geometries );
44+
return new GeometryCollection($geometries);
4245
}
43-
4446
}

src/Geometries/Geometry.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php namespace MStaack\LaravelPostgis\Geometries;
1+
<?php
2+
3+
namespace MStaack\LaravelPostgis\Geometries;
24

35
use GeoIO\WKB\Parser\Parser;
46
use MStaack\LaravelPostgis\Exceptions\UnknownWKTTypeException;

src/Geometries/GeometryCollection.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
<?php namespace MStaack\LaravelPostgis\Geometries;
1+
<?php
2+
3+
namespace MStaack\LaravelPostgis\Geometries;
24

35
use Countable;
4-
use GeoJson\GeoJson;
56
use InvalidArgumentException;
67

78
class GeometryCollection extends Geometry implements Countable

src/Geometries/GeometryInterface.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php namespace MStaack\LaravelPostgis\Geometries;
1+
<?php
2+
3+
namespace MStaack\LaravelPostgis\Geometries;
24

35
interface GeometryInterface
46
{

src/Geometries/LineString.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
<?php namespace MStaack\LaravelPostgis\Geometries;
1+
<?php
2+
3+
namespace MStaack\LaravelPostgis\Geometries;
24

35
class LineString extends PointCollection implements GeometryInterface
46
{
57
public function is3d()
68
{
7-
if(count($this->points) === 0) return false;
9+
if (count($this->points) === 0) return false;
810
return $this->points[0]->is3d();
911
}
1012

1113
public function toWKT()
1214
{
1315
$wktType = 'LINESTRING';
14-
if($this->is3d()) $wktType .= ' Z';
16+
if ($this->is3d()) $wktType .= ' Z';
1517
return sprintf('%s(%s)', $wktType, $this->toPairList());
1618
}
1719

0 commit comments

Comments
 (0)