Passed
Push — master ( 093d25...9ddd4f )
by Mr
01:54
created

Action   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 14
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A registerValidator() 0 3 1
A handleError() 0 7 1
1
<?php declare(strict_types=1);
2
/**
3
 * This file is part of the daikon-cqrs/boot project.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
namespace Daikon\Boot\Middleware\Action;
10
11
use Daikon\Boot\Middleware\Action\ActionInterface;
12
use Daikon\Boot\Middleware\ActionHandler;
13
use Psr\Http\Message\ServerRequestInterface;
14
15
abstract class Action implements ActionInterface
16
{
17
    public function registerValidator(ServerRequestInterface $request): ServerRequestInterface
18
    {
19
        return $request;
20
    }
21
22
    public function handleError(ServerRequestInterface $request): ServerRequestInterface
23
    {
24
        return $request->withAttribute(
25
            ActionHandler::ATTR_RESPONDER,
26
            [ErrorResponder::class, [
27
                ':message' => $request->getAttribute(ActionHandler::ATTR_STATUS_MESSAGE),
28
                ':statusCode' => $request->getAttribute(ActionHandler::ATTR_STATUS_CODE)
29
            ]]
30
        );
31
    }
32
}
33