Completed
Pull Request — develop (#745)
by Alejandro
05:29
created

AbstractRestAction::getRouteDef()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 2
dl 0
loc 7
rs 10
c 0
b 0
f 0
ccs 5
cts 5
cp 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Shlinkio\Shlink\Rest\Action;
6
7
use Fig\Http\Message\RequestMethodInterface;
8
use Fig\Http\Message\StatusCodeInterface;
9
use Psr\Http\Server\RequestHandlerInterface;
10
11
use function array_merge;
12
13
abstract class AbstractRestAction implements RequestHandlerInterface, RequestMethodInterface, StatusCodeInterface
14
{
15
    protected const ROUTE_PATH = '';
16
    protected const ROUTE_ALLOWED_METHODS = [];
17
18 1
    public static function getRouteDef(array $prevMiddleware = [], array $postMiddleware = []): array
19
    {
20
        return [
21 1
            'name' => static::class,
22 1
            'middleware' => array_merge($prevMiddleware, [static::class], $postMiddleware),
23 1
            'path' => static::ROUTE_PATH,
24 1
            'allowed_methods' => static::ROUTE_ALLOWED_METHODS,
25
        ];
26
    }
27
}
28