Skip to content

Commit 8c4277e

Browse files
committed
Upgrade to 3.0
1 parent 7c7d8fc commit 8c4277e

File tree

93 files changed

+7157
-1976
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+7157
-1976
lines changed

.gitattributes

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
/tests export-ignore
33
/.gitattributes export-ignore
44
/.gitignore export-ignore
5-
/.php_cs.dist export-ignore
5+
/.php-cs-fixer.dist.php export-ignore
66
/.travis.yml export-ignore
77
/phpstan.neon export-ignore
88
/phpunit.xml.dist export-ignore
9+
/infection.json.dist export-ignore

.github/workflows/ci.yml

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: ci
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- 'master'
8+
9+
jobs:
10+
ci:
11+
strategy:
12+
matrix:
13+
php-versions: [ '8.0', '8.1' ]
14+
composer-versions: ['update --prefer-dist', 'update --prefer-lowest']
15+
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v2
21+
22+
- name: Setup PHP
23+
uses: shivammathur/setup-php@v2
24+
with:
25+
php-version: ${{ matrix.php-versions }}
26+
coverage: xdebug
27+
28+
- name: Validate composer
29+
run: composer validate --no-check-publish
30+
31+
- name: Install Composer dependencies
32+
run: composer install --no-progress --prefer-dist --optimize-autoloader
33+
34+
- name: Setup composer versions
35+
run: composer ${{ matrix.composer-versions }}
36+
37+
- name: Run phpcsfixer
38+
run: vendor/bin/php-cs-fixer fix --dry-run --diff
39+
40+
- name: Phpstan
41+
run: vendor/bin/phpstan
42+
43+
- name: Run tests
44+
run: vendor/bin/phpunit --coverage-text --coverage-clover=.build/clover.xml --coverage-xml=.build/coverage --log-junit=.build/coverage/junit.xml
45+
46+
- name: Require 100% coverage
47+
run: vendor/bin/coverage-check .build/clover.xml 100
48+
49+
- name: Run infection
50+
run: vendor/bin/infection --skip-initial-tests --threads=8 --coverage=.build/coverage
51+
52+
- name: Check markdown links
53+
uses: actions/setup-node@v2
54+
run: |
55+
npm install markdown-link-check
56+
node_modules/.bin/markdown-link-check README.md

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
.phpunit.result.cache
2+
.php-cs-fixer.cache
13
/vendor
24
/.build

.php-cs-fixer.dist.php

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->in(__DIR__ . '/src')
5+
->in(__DIR__ . '/tests');
6+
7+
$config = new PhpCsFixer\Config();
8+
return $config->setRules([
9+
'@Symfony' => true,
10+
'strict_param' => true,
11+
'array_syntax' => ['syntax' => 'short'],
12+
'@PHP80Migration:risky' => true,
13+
'php_unit_construct' => true,
14+
'php_unit_strict' => true,
15+
])
16+
->setRiskyAllowed(true)
17+
->setFinder($finder);

.php_cs.dist

-12
This file was deleted.

.travis.yml

-16
This file was deleted.

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Changelog
2+
3+
- *3.0*
4+
- PHP 8 is required
5+
- All requests (request method) parameters has moved to the constructor
6+
- All responses now only has public parameters, no getters (only a few one exists)
7+
- Client needs to be added before running any requests

README.md

+32-13
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,44 @@
11
Rejseplanen - PHP API
22
---------------------
33

4-
[![Build Status](https://travis-ci.org/lsv/rejseplan-php-api.svg?branch=master)](https://travis-ci.org/lsv/rejseplan-php-api)
5-
[![codecov](https://codecov.io/gh/lsv/rejseplan-php-api/branch/master/graph/badge.svg)](https://codecov.io/gh/lsv/rejseplan-php-api)
6-
74
PHP wrapper for Rejseplanen.dk API
85

96
### Install
107

11-
`composer require lsv/rejseplan-php-api`
8+
```bash
9+
composer require lsv/rejseplan-php-api
10+
11+
# Add a PSR-18 client, fx
12+
composer require symfony/http-client
13+
# If you add another PSR18 client, then look below on how to use other PSR 18 clients
14+
```
15+
16+
17+
### Usage
18+
19+
```php
20+
$client = new \Symfony\Component\HttpClient\HttpClient(); // Any PSR-18 http client can be used
21+
\Lsv\Rejseplan\AbstractRequest::setClient($client);
22+
23+
$location = '123'; // Location should be either a string, integer or a StopLocation
24+
$board = new \Lsv\Rejseplan\ArrivalBoard($location);
25+
$response = $board->request();
26+
// $response is now a ArrivalBoardResponse
27+
```
28+
29+
See [ArrivalBoard](docs/ArrivalBoard.md) for more
1230

13-
### Usages
31+
### More usages
1432

15-
| Request | Description |
16-
| --- | --- |
17-
| [ArrivalBoard](ArrivalBoard.md) | To get arrival board for a station |
18-
| [DepartureBoard](DepartureBoard.md) | To get departure board for a station |
19-
| [Journey](Journey.md) | This will get you a full journey report for a vehicle |
20-
| [Location](Location.md) | With this you can find stops, POI or addresses from a user input |
21-
| [NearbyStops](NearbyStops.md) | This will deliver all stops within a radius of a given coordinate. |
22-
| [Trip](Trip.md) | With this you can calculate a trip |
33+
| Request | Description |
34+
|-------------------------------------|--------------------------------------------------------------------|
35+
| [Client](docs/Client.md) | Set HTTP client |
36+
| [ArrivalBoard](docs/ArrivalBoard.md) | To get arrival board for a station |
37+
| [DepartureBoard](docs/DepartureBoard.md) | To get departure board for a station |
38+
| [Journey](docs/Journey.md) | This will get you a full journey report for a vehicle |
39+
| [Location](docs/Location.md) | With this you can find stops, POI or addresses from a user input |
40+
| [NearbyStops](docs/NearbyStops.md) | This will deliver all stops within a radius of a given coordinate. |
41+
| [Trip](docs/Trip.md) | With this you can calculate a trip |
2342

2443
### License
2544

composer.json

+22-19
Original file line numberDiff line numberDiff line change
@@ -15,36 +15,39 @@
1515
}
1616
},
1717
"require": {
18+
"php": "^8.0",
1819
"ext-json": "*",
19-
"php": "^7.3",
20-
"symfony/http-client": "^4.3",
21-
"symfony/options-resolver": "^4.3",
22-
"symfony/serializer": "^4.3",
23-
"symfony/property-access": "^4.3",
24-
"symfony/property-info": "^4.3",
25-
"phpdocumentor/reflection-docblock": "^4.3"
20+
"symfony/options-resolver": "^6.0",
21+
"symfony/serializer": "^6.0",
22+
"symfony/property-access": "^6.0",
23+
"symfony/property-info": "^6.0",
24+
"psr/http-client": "^1.0",
25+
"nyholm/psr7": "^1.4"
2626
},
2727
"autoload-dev": {
2828
"psr-4": {
2929
"Lsv\\RejseplanTest\\": "tests"
3030
}
3131
},
3232
"require-dev": {
33-
"symfony/phpunit-bridge": "^4.0"
33+
"symfony/phpunit-bridge": "^6.0",
34+
"phpunit/phpunit": "^9.5",
35+
"friendsofphp/php-cs-fixer": "^3.5",
36+
"sebastian/phpcpd": "^6.0",
37+
"phpstan/phpstan": "^1.4",
38+
"symfony/http-client": "^6.0",
39+
"php-http/mock-client": "^1.5",
40+
"symfony/var-dumper": "^6.0",
41+
"infection/infection": "^0.26.1",
42+
"rregeer/phpunit-coverage-check": "^0.3.1"
3443
},
3544
"scripts": {
3645
"fix": [
37-
"curl -OL https://get.sensiolabs.org/security-checker.phar && php security-checker.phar security:check composer.lock && rm security-checker.phar",
38-
"curl -OL https://cs.sensiolabs.org/download/php-cs-fixer-v2.phar && php php-cs-fixer-v2.phar fix --using-cache false --allow-risky=yes && rm php-cs-fixer-v2.phar",
39-
"curl -OL https://phar.phpunit.de/phpcpd.phar && php phpcpd.phar src/ --min-lines=50 && rm phpcpd.phar",
40-
"curl -o phpstan.phar -OL https://phpstan-downloader.aarhof.eu && php phpstan.phar analyse src -l 7 && rm phpstan.phar",
41-
"vendor/bin/simple-phpunit"
42-
],
43-
"test": [
44-
"curl -OL https://get.sensiolabs.org/security-checker.phar && php security-checker.phar security:check composer.lock && rm security-checker.phar",
45-
"curl -OL https://cs.sensiolabs.org/download/php-cs-fixer-v2.phar && php php-cs-fixer-v2.phar fix --dry-run --using-cache false --diff --allow-risky=yes && rm php-cs-fixer-v2.phar",
46-
"curl -OL https://phar.phpunit.de/phpcpd.phar && php phpcpd.phar src/ --min-lines=50 && rm phpcpd.phar",
47-
"curl -o phpstan.phar -OL https://phpstan-downloader.aarhof.eu && php phpstan.phar analyse src -l 7 && rm phpstan.phar"
46+
"php-cs-fixer fix",
47+
"phpstan",
48+
"simple-phpunit --coverage-text --coverage-clover=.build/clover.xml --coverage-xml=.build/coverage --log-junit=.build/coverage/junit.xml",
49+
"coverage-check .build/clover.xml 100",
50+
"infection --skip-initial-tests --threads=8 --coverage=.build/coverage"
4851
]
4952
}
5053
}

0 commit comments

Comments
 (0)