Skip to content

Commit c998cc0

Browse files
MatanYadaevMatan Yadaev
andauthored
Add Doctrine types (#65)
* Move DB config to phpunit.xml * Add test * Implementation * Ignore PhpStan error * add geometrycollection type * dont register if doctrine isn't available * Formatting Co-authored-by: Matan Yadaev <[email protected]>
1 parent e511d64 commit c998cc0

13 files changed

+279
-11
lines changed

composer.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"phayes/geophp": "^1.2"
1818
},
1919
"require-dev": {
20+
"doctrine/dbal": "^3.4",
2021
"friendsofphp/php-cs-fixer": "^3.0",
2122
"jubeki/laravel-code-style": "^1.0",
2223
"nunomaduro/larastan": "^1.0|^2.0",
@@ -48,5 +49,12 @@
4849
}
4950
},
5051
"minimum-stability": "dev",
51-
"prefer-stable": true
52+
"prefer-stable": true,
53+
"extra": {
54+
"laravel": {
55+
"providers": [
56+
"MatanYadaev\\EloquentSpatial\\EloquentSpatialServiceProvider"
57+
]
58+
}
59+
}
5260
}

phpstan.neon

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ parameters:
1212
-
1313
message: '#^Access to an undefined property Pest\\Expectation\|Pest\\Support\\Extendable\:\:\$.+\.$#'
1414
path: tests/*.php
15+
-
16+
message: '#^Call to an undefined method Pest\\Expectation\:\:.+\(\)\.$#'
17+
path: tests/*.php
1518
excludePaths:
1619
- ./src/Factory.php
1720
checkMissingIterableValueType: true

phpunit.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,8 @@
2828
<logging>
2929
<junit outputFile="build/report.junit.xml"/>
3030
</logging>
31+
<php>
32+
<env name="DB_DATABASE" value="laravel_eloquent_spatial_test"/>
33+
<env name="DB_USERNAME" value="root"/>
34+
</php>
3135
</phpunit>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace MatanYadaev\EloquentSpatial\Doctrine;
6+
7+
use Doctrine\DBAL\Platforms\AbstractPlatform;
8+
use Doctrine\DBAL\Types\Type;
9+
10+
class GeometryCollectionType extends Type
11+
{
12+
public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
13+
{
14+
// @codeCoverageIgnoreStart
15+
return 'geometrycollection';
16+
// @codeCoverageIgnoreEnd
17+
}
18+
19+
public function getName(): string
20+
{
21+
return 'geometrycollection';
22+
}
23+
}

src/Doctrine/LineStringType.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace MatanYadaev\EloquentSpatial\Doctrine;
6+
7+
use Doctrine\DBAL\Platforms\AbstractPlatform;
8+
use Doctrine\DBAL\Types\Type;
9+
10+
class LineStringType extends Type
11+
{
12+
public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
13+
{
14+
// @codeCoverageIgnoreStart
15+
return 'linestring';
16+
// @codeCoverageIgnoreEnd
17+
}
18+
19+
public function getName(): string
20+
{
21+
return 'linestring';
22+
}
23+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace MatanYadaev\EloquentSpatial\Doctrine;
6+
7+
use Doctrine\DBAL\Platforms\AbstractPlatform;
8+
use Doctrine\DBAL\Types\Type;
9+
10+
class MultiLineStringType extends Type
11+
{
12+
public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
13+
{
14+
// @codeCoverageIgnoreStart
15+
return 'multilinestring';
16+
// @codeCoverageIgnoreEnd
17+
}
18+
19+
public function getName(): string
20+
{
21+
return 'multilinestring';
22+
}
23+
}

src/Doctrine/MultiPointType.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace MatanYadaev\EloquentSpatial\Doctrine;
6+
7+
use Doctrine\DBAL\Platforms\AbstractPlatform;
8+
use Doctrine\DBAL\Types\Type;
9+
10+
class MultiPointType extends Type
11+
{
12+
public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
13+
{
14+
// @codeCoverageIgnoreStart
15+
return 'multipoint';
16+
// @codeCoverageIgnoreEnd
17+
}
18+
19+
public function getName(): string
20+
{
21+
return 'multipoint';
22+
}
23+
}

src/Doctrine/MultiPolygonType.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace MatanYadaev\EloquentSpatial\Doctrine;
6+
7+
use Doctrine\DBAL\Platforms\AbstractPlatform;
8+
use Doctrine\DBAL\Types\Type;
9+
10+
class MultiPolygonType extends Type
11+
{
12+
public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
13+
{
14+
// @codeCoverageIgnoreStart
15+
return 'multipolygon';
16+
// @codeCoverageIgnoreEnd
17+
}
18+
19+
public function getName(): string
20+
{
21+
return 'multipolygon';
22+
}
23+
}

src/Doctrine/PointType.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace MatanYadaev\EloquentSpatial\Doctrine;
6+
7+
use Doctrine\DBAL\Platforms\AbstractPlatform;
8+
use Doctrine\DBAL\Types\Type;
9+
10+
class PointType extends Type
11+
{
12+
public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
13+
{
14+
// @codeCoverageIgnoreStart
15+
return 'point';
16+
// @codeCoverageIgnoreEnd
17+
}
18+
19+
public function getName(): string
20+
{
21+
return 'point';
22+
}
23+
}

src/Doctrine/PolygonType.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace MatanYadaev\EloquentSpatial\Doctrine;
6+
7+
use Doctrine\DBAL\Platforms\AbstractPlatform;
8+
use Doctrine\DBAL\Types\Type;
9+
10+
class PolygonType extends Type
11+
{
12+
public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
13+
{
14+
// @codeCoverageIgnoreStart
15+
return 'polygon';
16+
// @codeCoverageIgnoreEnd
17+
}
18+
19+
public function getName(): string
20+
{
21+
return 'polygon';
22+
}
23+
}

0 commit comments

Comments
 (0)