Skip to content

Commit 1899a04

Browse files
authored
Merge pull request #11 from lsv/feature/3.0
Feature/4.0
2 parents 7c7d8fc + f22945f commit 1899a04

File tree

93 files changed

+7165
-1973
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

+7165
-1973
lines changed

.gitattributes

Lines changed: 2 additions & 1 deletion
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

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

.gitignore

Lines changed: 2 additions & 0 deletions
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

Lines changed: 17 additions & 0 deletions
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

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

.travis.yml

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

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Changelog
2+
3+
- *4.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

Lines changed: 32 additions & 13 deletions
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

Lines changed: 22 additions & 19 deletions
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)