Redirect::process()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
declare(strict_types=1);
3
4
namespace Acelaya\Website\Action;
5
6
use Interop\Http\ServerMiddleware\DelegateInterface;
7
use Interop\Http\ServerMiddleware\MiddlewareInterface;
8
use Psr\Http\Message\ResponseInterface;
9
use Psr\Http\Message\ServerRequestInterface;
10
use Zend\Diactoros\Response\RedirectResponse;
11
12
class Redirect implements MiddlewareInterface
13
{
14
    /**
15
     * Process an incoming server request and return a response, optionally delegating
16
     * to the next middleware component to create the response.
17
     *
18
     * @param ServerRequestInterface $request
19
     * @param DelegateInterface $delegate
20
     *
21
     * @return ResponseInterface
22
     */
23
    public function process(ServerRequestInterface $request, DelegateInterface $delegate)
24
    {
25
        $to = $request->getAttribute('to');
26
        return new RedirectResponse($to, 301);
27
    }
28
}
29