Skip to content

Commit c78124c

Browse files
authored
Automatically apply code style fixes (#28)
1 parent db41297 commit c78124c

39 files changed

Lines changed: 290 additions & 355 deletions

.github/workflows/php-cs-fixer.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Check & fix styling
2+
3+
on: [push]
4+
5+
jobs:
6+
php-cs-fixer:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- name: Checkout code
11+
uses: actions/checkout@v2
12+
with:
13+
ref: ${{ github.head_ref }}
14+
15+
- name: Run PHP CS Fixer
16+
uses: docker://oskarstark/php-cs-fixer-ga
17+
with:
18+
args: --config=.php-cs-fixer.php --allow-risky=yes
19+
20+
- name: Commit changes
21+
uses: stefanzweifel/git-auto-commit-action@v4
22+
with:
23+
commit_message: Fix styling

src/Contracts/FileReader.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ abstract class FileReader
2727
{
2828
protected static function openFile($path)
2929
{
30-
if (!(is_readable($path) && is_file($path))) {
30+
if (! (is_readable($path) && is_file($path))) {
3131
throw new Exception("File [$path] not readable");
3232
}
3333
$handle = fopen($path, 'r');
34-
if (!$handle) {
34+
if (! $handle) {
3535
throw new Exception("Unable to read [$path] as binary file");
3636
}
3737

@@ -40,11 +40,11 @@ protected static function openFile($path)
4040

4141
protected static function openFileBinary($path, $position = 0)
4242
{
43-
if (!(is_readable($path) && is_file($path))) {
43+
if (! (is_readable($path) && is_file($path))) {
4444
throw new Exception("File [$path] not readable");
4545
}
4646
$handle = fopen($path, 'rb');
47-
if (!$handle) {
47+
if (! $handle) {
4848
throw new Exception("Unable to read [$path] as binary file");
4949
}
5050

src/Exception/StoreNotFoundException.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ public function __construct($message)
3535
parent::__construct($message, 404);
3636
}
3737

38-
3938
/**
4039
* Create a store not found exception for a data store
4140
*

src/GeoFile.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,13 @@ class GeoFile
6666
*/
6767
protected $type;
6868

69-
7069
public function __construct($path)
7170
{
7271
$this->file = new SplFileInfo($path);
7372

7473
list($format, $type, $mimeType) = TypeResolver::identify($path);
7574

76-
if (!in_array($format, TypeResolver::supportedFormats())) {
75+
if (! in_array($format, TypeResolver::supportedFormats())) {
7776
throw new UnsupportedFileException($path, $format, join(', ', TypeResolver::supportedFormats()));
7877
}
7978

@@ -131,13 +130,11 @@ public function content()
131130
return file_get_contents($this->file->getRealPath());
132131
}
133132

134-
135133
public function __get($property)
136134
{
137135
return $this->$property;
138136
}
139137

140-
141138
/**
142139
* Copy the GeoFile content into a temporary folder and return the new GeoFile instance
143140
*
@@ -172,8 +169,6 @@ public static function load($path)
172169
return static::from($path);
173170
}
174171

175-
176-
177172
/**
178173
* Check if the specified file is a valid geographical file
179174
*

src/GeoServer.php

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,12 @@
2424
use Exception;
2525
use OneOffTech\GeoServer\Http\Routes;
2626
use OneOffTech\GeoServer\Models\Style;
27-
use Psr\Http\Message\ResponseInterface;
2827
use OneOffTech\GeoServer\Models\Feature;
2928
use OneOffTech\GeoServer\Models\Resource;
3029
use OneOffTech\GeoServer\Models\DataStore;
3130
use OneOffTech\GeoServer\Models\Workspace;
3231
use OneOffTech\GeoServer\Support\ZipReader;
3332
use OneOffTech\GeoServer\Support\WmsOptions;
34-
use OneOffTech\GeoServer\Models\CoverageStore;
35-
use OneOffTech\GeoServer\Support\ImageResponse;
3633
use OneOffTech\GeoServer\Http\InteractsWithHttp;
3734
use OneOffTech\GeoServer\Auth\NullAuthentication;
3835
use OneOffTech\GeoServer\Contracts\Authentication;
@@ -47,7 +44,6 @@
4744
use OneOffTech\GeoServer\Http\Responses\CoverageStoreResponse;
4845
use OneOffTech\GeoServer\Exception\StyleAlreadyExistsException;
4946
use OneOffTech\GeoServer\Http\Responses\CoverageStoresResponse;
50-
use OneOffTech\GeoServer\Exception\AuthTypeNotSupportedException;
5147

5248
final class GeoServer
5349
{
@@ -90,7 +86,6 @@ public function version()
9086
return "$geoserver->Version";
9187
}
9288

93-
9489
/**
9590
* Retrieve the workspace information.
9691
*
@@ -214,7 +209,6 @@ public function feature($datastore, $name = null)
214209
return $response->feature;
215210
}
216211

217-
218212
/**
219213
* Retrieve the list of coverage stores defined in the workspace.
220214
* A data store contains raster format spatial data.
@@ -321,7 +315,7 @@ public function upload(GeoFile $file)
321315
$nameWithoutExtension = rtrim($file->name, $file->extension);
322316

323317
// check the content if modifications are required
324-
if (!in_array("$nameWithoutExtension.shp", $contentList)) {
318+
if (! in_array("$nameWithoutExtension.shp", $contentList)) {
325319

326320
// if yes, clone the content and do the filename edits to
327321
// make sure that files inside the zip are correctly named
@@ -361,7 +355,6 @@ public function details(GeoFile $file)
361355
return $this->coverage($file->name);
362356
}
363357

364-
365358
/**
366359
* Check if a specified GeoFile was uploaded to the Geoserver
367360
* The check will attempt to find the store that matches the given name
@@ -376,7 +369,7 @@ public function exist(GeoFile $file)
376369
try {
377370
$found = $this->{$store}($file->name);
378371

379-
if (!is_null($found)) {
372+
if (! is_null($found)) {
380373
return true;
381374
}
382375

@@ -408,7 +401,6 @@ public function remove(GeoFile $data)
408401
return false;
409402
}
410403

411-
412404
/**
413405
* Get the Web Map Service (WMS) map URL for the specified resource
414406
*
@@ -417,7 +409,7 @@ public function remove(GeoFile $data)
417409
*/
418410
public function wmsMapUrl($data, ?WmsOptions $wmsOptions = null)
419411
{
420-
if (!($data instanceof GeoFile || $data instanceof Resource)) {
412+
if (! ($data instanceof GeoFile || $data instanceof Resource)) {
421413
throw new InvalidArgumentException("Data must be a GeoFile or Resource instance.");
422414
}
423415

@@ -431,7 +423,6 @@ public function wmsMapUrl($data, ?WmsOptions $wmsOptions = null)
431423
return $this->routes->wms($this->workspace, $options);
432424
}
433425

434-
435426
/**
436427
* Attempt to retrieve a thumbnail of a previously uploaded
437428
* GeoFile or Resource using the Web Map Service
@@ -441,7 +432,7 @@ public function wmsMapUrl($data, ?WmsOptions $wmsOptions = null)
441432
*/
442433
public function thumbnail($data, $width = 300, $height = 300)
443434
{
444-
if (!($data instanceof GeoFile || $data instanceof Resource)) {
435+
if (! ($data instanceof GeoFile || $data instanceof Resource)) {
445436
throw new InvalidArgumentException("Data must be a GeoFile or Resource instance.");
446437
}
447438

@@ -456,8 +447,6 @@ public function thumbnail($data, $width = 300, $height = 300)
456447
return $this->getImage($url);
457448
}
458449

459-
460-
461450
/**
462451
* Get a style by its name.
463452
* The style must be in the current workspace
@@ -513,8 +502,7 @@ public function uploadStyle(StyleFile $file)
513502
$filePostRoute = $this->routes->url("workspaces/$this->workspace/styles");
514503

515504
try {
516-
$postFileResponse = $this->postFile($filePostRoute . '?name=' . $file->name, $file);
517-
505+
$postFileResponse = $this->postFile($filePostRoute.'?name='.$file->name, $file);
518506
} catch (ErrorResponseException $ex) {
519507
// we receive a 500 error response if the style already exists
520508
if ($ex->getData() === "Style named '$file->name' already exists in workspace $this->workspace") {

src/GeoType.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ final class GeoType
3636
*/
3737
const RASTER = "raster";
3838

39-
4039
/**
4140
* Get the GeoServer store for the specified type
4241
*

src/Http/InteractsWithHttp.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@
2626
use Http\Client\HttpClient;
2727
use Http\Message\MessageFactory;
2828
use Psr\Http\Message\ResponseInterface;
29-
use OneOffTech\GeoServer\Http\ResponseHelper;
3029
use OneOffTech\GeoServer\Support\ImageResponse;
31-
use OneOffTech\GeoServer\Exception\InvalidDataException;
3230
use OneOffTech\GeoServer\Exception\ErrorResponseException;
3331
use OneOffTech\GeoServer\Exception\SerializationException;
3432
use OneOffTech\GeoServer\Exception\DeserializationException;
@@ -51,7 +49,6 @@ trait InteractsWithHttp
5149
*/
5250
private $serializer;
5351

54-
5552
/**
5653
* @param ResponseInterface $response
5754
* @throws ErrorResponseException
@@ -60,14 +57,14 @@ private function checkResponseError(ResponseInterface $response)
6057
{
6158
$responseBody = $response->getBody();
6259
$contentTypeHeader = $response->getHeader('Content-Type');
63-
$contentType = !empty($contentTypeHeader) ? $contentTypeHeader[0] : '';
60+
$contentType = ! empty($contentTypeHeader) ? $contentTypeHeader[0] : '';
6461
if ($response->getStatusCode() !== 200 && $response->getStatusCode() !== 201 && $response->getStatusCode() !== 204) {
6562
if ($response->getStatusCode() === 500 && strpos($contentType, 'text/html')!== false) {
6663
$reason = substr((string)$responseBody, 0, 500);
6764

6865
throw new ErrorResponseException($reason, $response->getStatusCode(), (string)$responseBody);
6966
}
70-
throw new ErrorResponseException(!empty($response->getReasonPhrase()) ? $response->getReasonPhrase() : 'There was a problem in fulfilling your request.', $response->getStatusCode(), (string)$responseBody);
67+
throw new ErrorResponseException(! empty($response->getReasonPhrase()) ? $response->getReasonPhrase() : 'There was a problem in fulfilling your request.', $response->getStatusCode(), (string)$responseBody);
7168
}
7269
}
7370

@@ -182,10 +179,10 @@ protected function getImage($route)
182179
$response = $this->handleRequest($request);
183180

184181
$contentTypeHeader = $response->getHeader('Content-Type');
185-
$contentType = !empty($contentTypeHeader) ? $contentTypeHeader[0] : '';
182+
$contentType = ! empty($contentTypeHeader) ? $contentTypeHeader[0] : '';
186183

187184
if ($response->getStatusCode() !== 200 && $response->getStatusCode() !== 201 && $response->getStatusCode() !== 204) {
188-
throw new ErrorResponseException(!empty($response->getReasonPhrase()) ? $response->getReasonPhrase() : 'There was a problem in fulfilling your request.', $response->getStatusCode(), (string)$responseBody);
185+
throw new ErrorResponseException(! empty($response->getReasonPhrase()) ? $response->getReasonPhrase() : 'There was a problem in fulfilling your request.', $response->getStatusCode(), (string)$responseBody);
189186
}
190187

191188
if (strpos($contentType, 'image') === false) {

src/Http/ResponseHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class ResponseHelper
3434
*/
3535
public static function isAssociativeArray($array)
3636
{
37-
if (empty($array) || !is_array($array)) {
37+
if (empty($array) || ! is_array($array)) {
3838
return false;
3939
}
4040

src/Http/Responses/CoverageStoreResponse.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
namespace OneOffTech\GeoServer\Http\Responses;
2323

2424
use JMS\Serializer\Annotation as JMS;
25-
use OneOffTech\GeoServer\Models\Coverage;
2625

2726
class CoverageStoreResponse
2827
{

src/Http/Responses/CoverageStoresResponse.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
namespace OneOffTech\GeoServer\Http\Responses;
2323

2424
use JMS\Serializer\Annotation as JMS;
25-
use OneOffTech\GeoServer\Models\Coverage;
2625

2726
class CoverageStoresResponse
2827
{

0 commit comments

Comments
 (0)