Skip to content

Commit 3becc00

Browse files
committed
Switch to http-server-middleware
1 parent 4057ff4 commit 3becc00

File tree

5 files changed

+22
-27
lines changed

5 files changed

+22
-27
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ language: php
22
sudo: false
33

44
php:
5-
- 5.6
65
- 7.0
76
- 7.1
87

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

7+
## UNRELEASED
8+
9+
### Removed
10+
11+
* Removed support for PHP 5.x.
12+
13+
### Changed
14+
15+
* Replaced `http-interop/http-middleware` with `http-interop/http-server-middleware`.
16+
717
## [0.4.0] - 2017-09-21
818

919
### Changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Middleware to normalize the trailing slash of the uri path. By default removes t
1111

1212
## Requirements
1313

14-
* PHP >= 5.6
14+
* PHP >= 7.0
1515
* A [PSR-7](https://packagist.org/providers/psr/http-message-implementation) http mesage implementation ([Diactoros](https://github.com/zendframework/zend-diactoros), [Guzzle](https://github.com/guzzle/psr7), [Slim](https://github.com/slimphp/Slim), etc...)
1616
* A [PSR-15](https://github.com/http-interop/http-middleware) middleware dispatcher ([Middleman](https://github.com/mindplay-dk/middleman), etc...)
1717

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
"issues": "https://github.com/middlewares/trailing-slash/issues"
1818
},
1919
"require": {
20-
"php": "^5.6 || ^7.0",
21-
"http-interop/http-middleware": "^0.5",
22-
"middlewares/utils": "~0.12"
20+
"php": "^7.0",
21+
"middlewares/utils": "~0.13",
22+
"http-interop/http-server-middleware": "^1.0"
2323
},
2424
"require-dev": {
25-
"phpunit/phpunit": "^5.5 || ^6.0",
25+
"phpunit/phpunit": "^6.0",
2626
"zendframework/zend-diactoros": "^1.3",
2727
"friendsofphp/php-cs-fixer": "^2.0",
2828
"squizlabs/php_codesniffer": "^3.0"

src/TrailingSlash.php

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
declare(strict_types = 1);
23

34
namespace Middlewares;
45

@@ -21,37 +22,26 @@ class TrailingSlash implements MiddlewareInterface
2122

2223
/**
2324
* Configure whether add or remove the slash.
24-
*
25-
* @param bool $trailingSlash
2625
*/
27-
public function __construct($trailingSlash = false)
26+
public function __construct(bool $trailingSlash = false)
2827
{
29-
$this->trailingSlash = (bool) $trailingSlash;
28+
$this->trailingSlash = $trailingSlash;
3029
}
3130

3231
/**
3332
* Whether returns a 301 response to the new path.
34-
*
35-
* @param bool $redirect
36-
*
37-
* @return self
3833
*/
39-
public function redirect($redirect = true)
34+
public function redirect(bool $redirect = true): self
4035
{
41-
$this->redirect = (bool) $redirect;
36+
$this->redirect = $redirect;
4237

4338
return $this;
4439
}
4540

4641
/**
4742
* Process a request and return a response.
48-
*
49-
* @param ServerRequestInterface $request
50-
* @param RequestHandlerInterface $handler
51-
*
52-
* @return ResponseInterface
5343
*/
54-
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler)
44+
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
5545
{
5646
$uri = $request->getUri();
5747
$path = $this->normalize($uri->getPath());
@@ -66,12 +56,8 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
6656

6757
/**
6858
* Normalize the trailing slash.
69-
*
70-
* @param string $path
71-
*
72-
* @return string
7359
*/
74-
private function normalize($path)
60+
private function normalize(string $path): string
7561
{
7662
if ($path === '') {
7763
return '/';

0 commit comments

Comments
 (0)