Skip to content

Commit db0bef3

Browse files
committed
wip
1 parent d39caa8 commit db0bef3

File tree

4 files changed

+118
-11
lines changed

4 files changed

+118
-11
lines changed

composer.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"friendsofphp/php-cs-fixer": "^2.17",
2626
"matt-allan/laravel-code-style": "^0.6.0",
2727
"nunomaduro/larastan": "^0.7.0",
28+
"nunomaduro/phpinsights": "dev-feature/php8-and-github-action",
2829
"orchestra/testbench": "^6.0",
2930
"phpunit/phpunit": "^9.3"
3031
},
@@ -43,10 +44,11 @@
4344
}
4445
},
4546
"scripts": {
46-
"php-cs-fixer": "./vendor/bin/php-cs-fixer fix --allow-risky=yes",
47-
"phpstan": "vendor/bin/phpstan analyse --memory-limit=2G",
48-
"test": "vendor/bin/phpunit --colors=always",
49-
"test-coverage": "vendor/bin/phpunit --coverage-html coverage"
47+
"style-fix": "./vendor/bin/php-cs-fixer fix --allow-risky=yes",
48+
"phpstan": "./vendor/bin/phpstan analyse --memory-limit=2G",
49+
"phpunit": "./vendor/bin/phpunit --colors=always",
50+
"phpunit-coverage": "./vendor/bin/phpunit --coverage-html coverage",
51+
"phpinsights": "./vendor/bin/phpinsights"
5052
},
5153
"config": {
5254
"sort-packages": true

phpinsights.php

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
return [
6+
7+
/*
8+
|--------------------------------------------------------------------------
9+
| Default Preset
10+
|--------------------------------------------------------------------------
11+
|
12+
| This option controls the default preset that will be used by PHP Insights
13+
| to make your code reliable, simple, and clean. However, you can always
14+
| adjust the `Metrics` and `Insights` below in this configuration file.
15+
|
16+
| Supported: "default", "laravel", "symfony", "magento2", "drupal"
17+
|
18+
*/
19+
20+
'preset' => 'default',
21+
22+
/*
23+
|--------------------------------------------------------------------------
24+
| IDE
25+
|--------------------------------------------------------------------------
26+
|
27+
| This options allow to add hyperlinks in your terminal to quickly open
28+
| files in your favorite IDE while browsing your PhpInsights report.
29+
|
30+
| Supported: "textmate", "macvim", "emacs", "sublime", "phpstorm",
31+
| "atom", "vscode".
32+
|
33+
| If you have another IDE that is not in this list but which provide an
34+
| url-handler, you could fill this config with a pattern like this:
35+
|
36+
| myide://open?url=file://%f&line=%l
37+
|
38+
*/
39+
40+
'ide' => 'phpstorm',
41+
42+
/*
43+
|--------------------------------------------------------------------------
44+
| Configuration
45+
|--------------------------------------------------------------------------
46+
|
47+
| Here you may adjust all the various `Insights` that will be used by PHP
48+
| Insights. You can either add, remove or configure `Insights`. Keep in
49+
| mind, that all added `Insights` must belong to a specific `Metric`.
50+
|
51+
*/
52+
53+
'exclude' => [
54+
// 'path/to/directory-or-file'
55+
],
56+
57+
'add' => [
58+
// ExampleMetric::class => [
59+
// ExampleInsight::class,
60+
// ]
61+
],
62+
63+
'remove' => [
64+
// ExampleInsight::class,
65+
],
66+
67+
'config' => [
68+
// ExampleInsight::class => [
69+
// 'key' => 'value',
70+
// ],
71+
],
72+
73+
/*
74+
|--------------------------------------------------------------------------
75+
| Requirements
76+
|--------------------------------------------------------------------------
77+
|
78+
| Here you may define a level you want to reach per `Insights` category.
79+
| When a score is lower than the minimum level defined, then an error
80+
| code will be returned. This is optional and individually defined.
81+
|
82+
*/
83+
84+
'requirements' => [
85+
// 'min-quality' => 0,
86+
// 'min-complexity' => 0,
87+
// 'min-architecture' => 0,
88+
// 'min-style' => 0,
89+
// 'disable-security-check' => false,
90+
],
91+
92+
/*
93+
|--------------------------------------------------------------------------
94+
| Threads
95+
|--------------------------------------------------------------------------
96+
|
97+
| Here you may adjust how many threads (core) PHPInsights can use to perform
98+
| the analyse. This is optional, don't provide it and the tool will guess
99+
| the max core number available. This accept null value or integer > 0.
100+
|
101+
*/
102+
103+
'threads' => null,
104+
105+
];

src/Builders/SpatialBuilder.php

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

99
class SpatialBuilder extends Builder
1010
{
11-
public function withDistance(string $column, Geometry | string $geometryOrColumn, string $as = 'distance'): self
11+
public function withDistance(string $column, Geometry | string $geometryOrColumn, string $alias = 'distance'): self
1212
{
1313
$geometryOrColumn = $this->toExpression($geometryOrColumn);
1414

1515
if (! $this->getQuery()->columns) {
1616
$this->select('*');
1717
}
1818

19-
return $this->selectRaw("ST_DISTANCE(`{$column}`, {$geometryOrColumn}) AS {$as}");
19+
return $this->selectRaw("ST_DISTANCE(`{$column}`, {$geometryOrColumn}) AS {$alias}");
2020
}
2121

2222
public function whereDistance(string $column, Geometry | string $geometryOrColumn, string $operator, int | float $distance): self
2323
{
2424
$geometryOrColumn = $this->toExpression($geometryOrColumn);
2525

26-
$this->whereRaw("ST_DISTANCE(`{$column}`, {$geometryOrColumn}) {$operator} $distance");
26+
$this->whereRaw("ST_DISTANCE(`{$column}`, {$geometryOrColumn}) {$operator} {$distance}");
2727

2828
return $this;
2929
}
@@ -37,15 +37,15 @@ public function orderByDistance(string $column, Geometry | string $geometryOrCol
3737
return $this;
3838
}
3939

40-
public function withDistanceSphere(string $column, Geometry | string $geometryOrColumn, string $as = 'distance'): self
40+
public function withDistanceSphere(string $column, Geometry | string $geometryOrColumn, string $alias = 'distance'): self
4141
{
4242
$geometryOrColumn = $this->toExpression($geometryOrColumn);
4343

4444
if (! $this->getQuery()->columns) {
4545
$this->select('*');
4646
}
4747

48-
$this->selectRaw("ST_DISTANCE_SPHERE(`{$column}`, {$geometryOrColumn}) AS {$as}");
48+
$this->selectRaw("ST_DISTANCE_SPHERE(`{$column}`, {$geometryOrColumn}) AS {$alias}");
4949

5050
return $this;
5151
}

src/Objects/GeometryCollection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ protected function validateGeometriesCount(): void
4040
{
4141
$geometriesCount = $this->geometries->count();
4242
if ($geometriesCount < $this->minimumGeometries) {
43-
$className = get_class($this);
43+
$className = self::class;
4444

4545
throw new InvalidArgumentException("{$className} must contain at least {$this->minimumGeometries} ".Str::plural('entries', $geometriesCount));
4646
}
@@ -53,7 +53,7 @@ protected function validateGeometriesType(): void
5353
{
5454
$this->geometries->each(function (Geometry $geometry): void {
5555
if (! ($geometry instanceof $this->collectionOf)) {
56-
$className = get_class($this);
56+
$className = self::class;
5757

5858
throw new InvalidArgumentException("{$className} must be a collection of {$this->collectionOf}");
5959
}

0 commit comments

Comments
 (0)