Code Coverage  | 
      ||||||||||
Lines  | 
       Functions and Methods  | 
       Classes and Traits  | 
      ||||||||
| Total |         | 
       100.00%  | 
       5 / 5  | 
               | 
       100.00%  | 
       2 / 2  | 
       CRAP |         | 
       100.00%  | 
       1 / 1  | 
      
| SwaggerUIRedirectController |         | 
       100.00%  | 
       5 / 5  | 
               | 
       100.00%  | 
       2 / 2  | 
       3 |         | 
       100.00%  | 
       1 / 1  | 
      
| __construct |         | 
       100.00%  | 
       1 / 1  | 
               | 
       100.00%  | 
       1 / 1  | 
       2 | |||
| __invoke |         | 
       100.00%  | 
       4 / 4  | 
               | 
       100.00%  | 
       1 / 1  | 
       1 | |||
| 1 | <?php | 
| 2 | namespace Apie\RestApi\Controllers; | 
| 3 | |
| 4 | use Nyholm\Psr7\Factory\Psr17Factory; | 
| 5 | use Psr\Http\Message\ResponseInterface; | 
| 6 | use Psr\Http\Message\ServerRequestInterface; | 
| 7 | |
| 8 | class SwaggerUIRedirectController | 
| 9 | { | 
| 10 | private readonly string $htmlPath; | 
| 11 | |
| 12 | public function __construct( | 
| 13 | ?string $htmlPath = null | 
| 14 | ) { | 
| 15 | $this->htmlPath = null === $htmlPath ? __DIR__ . '/../../resources/swagger-ui/oauth2-redirect.html' : $htmlPath; | 
| 16 | } | 
| 17 | |
| 18 | public function __invoke(ServerRequestInterface $request): ResponseInterface | 
| 19 | { | 
| 20 | $psr17Factory = new Psr17Factory(); | 
| 21 | return $psr17Factory->createResponse(200) | 
| 22 | ->withBody($psr17Factory->createStream(file_get_contents($this->htmlPath))) | 
| 23 | ->withHeader('Content-Type', 'text/html'); | 
| 24 | } | 
| 25 | } |