Skip to content

Commit 43cc3ab

Browse files
committed
add ci
1 parent 4ca4c91 commit 43cc3ab

File tree

4 files changed

+50
-8
lines changed

4 files changed

+50
-8
lines changed

.github/workflows/phpinsights.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Code quality analysis
2+
3+
on: [push]
4+
5+
jobs:
6+
phpstan:
7+
name: PHPInsights
8+
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v2
14+
15+
- name: Setup PHP
16+
uses: shivammathur/setup-php@v2
17+
with:
18+
php-version: 8.0
19+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
20+
coverage: none
21+
22+
- name: Install dependencies
23+
run: composer install --prefer-dist --no-interaction
24+
25+
- name: Run PHPInsights
26+
run: ./vendor/bin/phpinsights --no-interaction --ansi --format=github-action

phpinsights.php

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
declare(strict_types=1);
44

5+
use NunoMaduro\PhpInsights\Domain\Insights\CyclomaticComplexityIsHigh;
56
use NunoMaduro\PhpInsights\Domain\Insights\ForbiddenNormalClasses;
67
use ObjectCalisthenics\Sniffs\Files\ClassTraitAndInterfaceLengthSniff;
8+
use ObjectCalisthenics\Sniffs\Files\FunctionLengthSniff;
79
use ObjectCalisthenics\Sniffs\Metrics\MaxNestingLevelSniff;
810
use ObjectCalisthenics\Sniffs\Metrics\MethodPerClassLimitSniff;
911
use PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\UselessOverridingMethodSniff;
@@ -94,6 +96,7 @@
9496
],
9597
UnusedParameterSniff::class => [
9698
'exclude' => [
99+
'src/Objects/Geometry.php',
97100
'src/Objects/GeometryCast.php',
98101
],
99102
],
@@ -108,6 +111,16 @@
108111
'src/Builders/SpatialBuilder.php',
109112
],
110113
],
114+
FunctionLengthSniff::class => [
115+
'exclude' => [
116+
'src/Factory.php',
117+
],
118+
],
119+
CyclomaticComplexityIsHigh::class => [
120+
'exclude' => [
121+
'src/Factory.php',
122+
],
123+
],
111124
],
112125

113126
/*
@@ -122,11 +135,11 @@
122135
*/
123136

124137
'requirements' => [
125-
// 'min-quality' => 0,
126-
// 'min-complexity' => 0,
127-
// 'min-architecture' => 0,
128-
// 'min-style' => 0,
129-
// 'disable-security-check' => false,
138+
'min-quality' => 90,
139+
'min-complexity' => 90,
140+
'min-architecture' => 90,
141+
'min-style' => 90,
142+
'disable-security-check' => false,
130143
],
131144

132145
/*

src/Factory.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ public static function parse(string $value): Geometry
3737
/** @var geoPHPGeometry $geoPHPGeometry */
3838
$geoPHPGeometry = geoPHP::load($value);
3939

40-
return self::create($geoPHPGeometry);
40+
return self::createFromGeometry($geoPHPGeometry);
4141
}
4242

43-
protected static function create(geoPHPGeometry $geometry): Geometry
43+
protected static function createFromGeometry(geoPHPGeometry $geometry): Geometry
4444
{
4545
if ($geometry instanceof geoPHPGeometryCollection) {
4646
$components = collect($geometry->components)
4747
->map(static function (geoPHPGeometry $geometryComponent): Geometry {
48-
return self::create($geometryComponent);
48+
return self::createFromGeometry($geometryComponent);
4949
});
5050

5151
$className = $geometry::class;

src/Objects/GeometryCast.php

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

3+
declare(strict_types=1);
4+
35
namespace MatanYadaev\EloquentSpatial\Objects;
46

57
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
@@ -40,6 +42,7 @@ public function get($model, string $key, $wkt, array $attributes): ?Geometry
4042
* @param array<string, mixed> $attributes
4143
*
4244
* @return Expression|string|null
45+
*
4346
* @throws InvalidTypeException
4447
*/
4548
public function set($model, string $key, $geometry, array $attributes): Expression | string | null

0 commit comments

Comments
 (0)