Skip to content

Commit 34579cf

Browse files
authored
Updated deps and applied code style (#1)
1 parent 06e1a8c commit 34579cf

File tree

11 files changed

+81
-100
lines changed

11 files changed

+81
-100
lines changed

.github/workflows/build.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: build
2+
on:
3+
push: ~
4+
pull_request: ~
5+
schedule:
6+
- cron: 5 8 * * 3
7+
jobs:
8+
checks:
9+
name: PHP ${{ matrix.php-versions }}
10+
runs-on: ${{ matrix.operating-system }}
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
operating-system: [ubuntu-latest]
15+
php-versions: ['7.2', '7.3', '7.4']
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v1
19+
- name: Setup PHP, with composer and extensions
20+
uses: shivammathur/setup-php@master
21+
with:
22+
php-version: ${{ matrix.php-versions }}
23+
extensions: mbstring
24+
- name: Install Composer dependencies
25+
run: composer update --no-progress --no-suggest --prefer-dist --no-interaction
26+
- name: Validate composer
27+
run: composer validate --strict
28+
- name: Check composer normalized
29+
run: composer normalize --dry-run
30+
- name: Check style
31+
run: composer check-style
32+
- name: Static analysis
33+
run: composer analyse
34+
- name: Run phpspec
35+
run: composer phpspec
36+
- name: Run phpunit
37+
run: composer phpunit

.travis.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2019 Joachim Løvgaard
3+
Copyright (c) 2020 Joachim Løvgaard
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![Latest Version][ico-version]][link-packagist]
44
[![Latest Unstable Version][ico-unstable-version]][link-packagist]
55
[![Software License][ico-license]](LICENSE)
6-
[![Build Status][ico-travis]][link-travis]
6+
[![Build Status][ico-github-actions]][link-github-actions]
77
[![Quality Score][ico-code-quality]][link-code-quality]
88

99
A PHP SDK for the [PostNord API](https://developer.postnord.com/api).
@@ -61,9 +61,9 @@ $client->get('findNearestByAddress.json', [
6161
[ico-version]: https://poser.pugx.org/setono/post-nord-php-sdk/v/stable
6262
[ico-unstable-version]: https://poser.pugx.org/setono/post-nord-php-sdk/v/unstable
6363
[ico-license]: https://poser.pugx.org/setono/post-nord-php-sdk/license
64-
[ico-travis]: https://travis-ci.com/Setono/post-nord-php-sdk.svg?branch=master
65-
[ico-code-quality]: https://img.shields.io/scrutinizer/g/Setono/post-nord-php-sdk.svg?style=flat-square
64+
[ico-github-actions]: https://github.com/Setono/post-nord-php-sdk/workflows/build/badge.svg
65+
[ico-code-quality]: https://img.shields.io/scrutinizer/g/Setono/post-nord-php-sdk.svg
6666

6767
[link-packagist]: https://packagist.org/packages/setono/post-nord-php-sdk
68-
[link-travis]: https://travis-ci.com/Setono/post-nord-php-sdk
68+
[link-github-actions]: https://github.com/Setono/post-nord-php-sdk/actions
6969
[link-code-quality]: https://scrutinizer-ci.com/g/Setono/post-nord-php-sdk

composer.json

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,19 @@
1414
"psr/http-client": "^1.0",
1515
"psr/http-factory": "^1.0",
1616
"psr/http-message": "^1.0",
17-
"thecodingmachine/safe": "^0.1.15"
17+
"thecodingmachine/safe": "^1.0"
1818
},
1919
"require-dev": {
20+
"ergebnis/composer-normalize": "^2.0",
21+
"korbeil/phpstan-generic-rules": "^0.2",
2022
"kriswallsmith/buzz": "^1.0",
21-
"localheinz/composer-normalize": "^1.1",
2223
"nyholm/psr7": "^1.1",
23-
"phpspec/phpspec": "^5.1",
24-
"phpstan/phpstan": "^0.10.3",
24+
"phpspec/phpspec": "^5.1 || ^6.0",
25+
"phpstan/phpstan": "^0.12",
26+
"phpstan/phpstan-strict-rules": "^0.12",
2527
"phpunit/phpunit": "^8.0",
26-
"symplify/easy-coding-standard": "^5.1",
27-
"thecodingmachine/phpstan-safe-rule": "^0.1.3"
28+
"sylius-labs/coding-standard": "^3.1",
29+
"thecodingmachine/phpstan-safe-rule": "^1.0beta"
2830
},
2931
"config": {
3032
"sort-packages": true
@@ -41,12 +43,14 @@
4143
},
4244
"prefer-stable": true,
4345
"scripts": {
44-
"analyse": "./vendor/bin/phpstan analyse -c phpstan.neon -l max src",
45-
"check-style": "./vendor/bin/ecs check --ansi src/ tests/ spec/",
46-
"fix-style": "./vendor/bin/ecs check --fix --ansi src/ tests/ spec/",
46+
"analyse": "vendor/bin/phpstan analyse -c phpstan.neon -l max src",
47+
"check-style": "vendor/bin/ecs check --ansi src/ tests/ spec/",
48+
"fix-style": "vendor/bin/ecs check --fix --ansi src/ tests/ spec/",
49+
"phpspec": "vendor/bin/phpspec run",
50+
"phpunit": "vendor/bin/phpunit",
4751
"test": [
48-
"./vendor/bin/phpspec run",
49-
"./vendor/bin/phpunit"
52+
"@phpspec",
53+
"@phpunit"
5054
]
5155
}
5256
}

easy-coding-standard.yaml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
11
imports:
2-
- { resource: 'vendor/symplify/easy-coding-standard/config/symfony.yml' }
3-
4-
services:
5-
PhpCsFixer\Fixer\Import\OrderedImportsFixer: ~
6-
PhpCsFixer\Fixer\Strict\DeclareStrictTypesFixer: ~
2+
- { resource: 'vendor/sylius-labs/coding-standard/easy-coding-standard.yml' }

phpstan.neon

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
includes:
2-
- vendor/thecodingmachine/phpstan-safe-rule/phpstan-safe-rule.neon
2+
- vendor/korbeil/phpstan-generic-rules/extension.neon
3+
- vendor/phpstan/phpstan-strict-rules/rules.neon
4+
- vendor/thecodingmachine/phpstan-safe-rule/phpstan-safe-rule.neon
35

46
parameters:
5-
excludes_analyse:
6-
# Test dependencies
7-
- 'tests/**.php'
7+
checkMissingIterableValueType: false
8+
9+
excludes_analyse:
10+
- 'tests/**.php'

spec/Client/ClientSpec.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
class ClientSpec extends ObjectBehavior
1919
{
2020
private const API_KEY = 'api_key';
21+
2122
private const BASE_URL = 'https://api2.postnord.com';
2223

2324
public function let(
@@ -45,7 +46,7 @@ public function it_gets(
4546
StreamInterface $stream
4647
): void {
4748
$requestFactory
48-
->createRequest('GET', self::BASE_URL.'/endpoint.json?apikey='.self::API_KEY.'&param1=value1&param2=value2')
49+
->createRequest('GET', self::BASE_URL . '/endpoint.json?apikey=' . self::API_KEY . '&param1=value1&param2=value2')
4950
->shouldBeCalled();
5051

5152
$response->getStatusCode()->willReturn(200);
@@ -72,7 +73,7 @@ public function it_posts(
7273
$request->withBody(Argument::any())->willReturn($request);
7374

7475
$requestFactory
75-
->createRequest('POST', self::BASE_URL.'/endpoint.json?apikey='.self::API_KEY.'&param1=value1&param2=value2')
76+
->createRequest('POST', self::BASE_URL . '/endpoint.json?apikey=' . self::API_KEY . '&param1=value1&param2=value2')
7677
->willReturn($request);
7778

7879
$streamFactory

src/Client/Client.php

Lines changed: 8 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Setono\PostNord\Client;
66

7+
use const PHP_QUERY_RFC3986;
78
use Psr\Http\Client\ClientExceptionInterface;
89
use Psr\Http\Client\ClientInterface as HttpClientInterface;
910
use Psr\Http\Message\RequestFactoryInterface;
@@ -16,29 +17,19 @@
1617

1718
final class Client implements ClientInterface
1819
{
19-
/**
20-
* @var HttpClientInterface
21-
*/
20+
/** @var HttpClientInterface */
2221
private $httpClient;
2322

24-
/**
25-
* @var RequestFactoryInterface
26-
*/
23+
/** @var RequestFactoryInterface */
2724
private $requestFactory;
2825

29-
/**
30-
* @var StreamFactoryInterface
31-
*/
26+
/** @var StreamFactoryInterface */
3227
private $streamFactory;
3328

34-
/**
35-
* @var string
36-
*/
29+
/** @var string */
3730
private $apiKey;
3831

39-
/**
40-
* @var string
41-
*/
32+
/** @var string */
4233
private $baseUrl;
4334

4435
public function __construct(
@@ -56,11 +47,6 @@ public function __construct(
5647
}
5748

5849
/**
59-
* @param string $endpoint
60-
* @param array $params
61-
*
62-
* @return array
63-
*
6450
* @throws ClientExceptionInterface
6551
* @throws JsonException
6652
* @throws StringsException
@@ -71,12 +57,6 @@ public function get(string $endpoint, array $params = []): array
7157
}
7258

7359
/**
74-
* @param string $endpoint
75-
* @param array $params
76-
* @param array $body
77-
*
78-
* @return array
79-
*
8060
* @throws ClientExceptionInterface
8161
* @throws JsonException
8262
* @throws StringsException
@@ -87,13 +67,6 @@ public function post(string $endpoint, array $params = [], array $body = []): ar
8767
}
8868

8969
/**
90-
* @param string $method
91-
* @param string $endpoint
92-
* @param array $params
93-
* @param array $body
94-
*
95-
* @return array
96-
*
9770
* @throws ClientExceptionInterface
9871
* @throws JsonException
9972
* @throws StringsException
@@ -104,11 +77,11 @@ private function sendRequest(string $method, string $endpoint, array $params = [
10477
'apikey' => $this->apiKey,
10578
], $params);
10679

107-
$url = $this->baseUrl.'/'.$endpoint.'?'.http_build_query($params, '', '&', PHP_QUERY_RFC3986);
80+
$url = $this->baseUrl . '/' . $endpoint . '?' . http_build_query($params, '', '&', PHP_QUERY_RFC3986);
10881

10982
$request = $this->requestFactory->createRequest($method, $url);
11083

111-
if (!empty($body)) {
84+
if (count($body) > 0) {
11285
$request = $request->withBody($this->streamFactory->createStream(json_encode($body)));
11386
}
11487

src/Client/ClientInterface.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,11 @@ interface ClientInterface
88
{
99
/**
1010
* Sends a GET request to the specified endpoint with the given query params.
11-
*
12-
* @param string $endpoint
13-
* @param array $params
14-
*
15-
* @return array
1611
*/
1712
public function get(string $endpoint, array $params = []): array;
1813

1914
/**
2015
* Sends a POST request to the specified endpoint with the given query params and specified body.
21-
*
22-
* @param string $endpoint
23-
* @param array $params
24-
* @param array $body
25-
*
26-
* @return array
2716
*/
2817
public function post(string $endpoint, array $params = [], array $body = []): array;
2918
}

0 commit comments

Comments
 (0)