Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 6 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
DevelopmentMiddleware | |
0.00% |
0 / 6 |
|
0.00% |
0 / 3 |
20 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
handleBefore | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
handleAfter | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace PeServer\App\Models\Middleware; |
6 | |
7 | use PeServer\Core\Environment; |
8 | use PeServer\Core\Http\HttpResponse; |
9 | use PeServer\Core\Http\HttpStatus; |
10 | use PeServer\Core\Log\ILogger; |
11 | use PeServer\Core\Mvc\Middleware\IMiddleware; |
12 | use PeServer\Core\Mvc\Middleware\MiddlewareArgument; |
13 | use PeServer\Core\Mvc\Middleware\MiddlewareResult; |
14 | |
15 | final class DevelopmentMiddleware implements IMiddleware |
16 | { |
17 | public function __construct( |
18 | private ILogger $logger |
19 | ) { |
20 | } |
21 | |
22 | //[IMiddleware] |
23 | |
24 | public function handleBefore(MiddlewareArgument $argument): MiddlewareResult |
25 | { |
26 | if ($argument->environment->isProduction()) { |
27 | $this->logger->warn('本番環境での実行は抑制'); |
28 | return MiddlewareResult::error(HttpStatus::Forbidden); |
29 | } |
30 | |
31 | return MiddlewareResult::none(); |
32 | } |
33 | |
34 | public function handleAfter(MiddlewareArgument $argument, HttpResponse $response): MiddlewareResult |
35 | { |
36 | return MiddlewareResult::none(); |
37 | } |
38 | } |