Failed Conditions
Push — master ( 165873...f80450 )
by Adrien
03:57
created

DownloadCounter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 6
c 1
b 0
f 0
dl 0
loc 12
ccs 0
cts 6
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 10 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Application\Handler;
6
7
use Ecodev\Felix\Handler\AbstractHandler;
8
use Laminas\Diactoros\Response\TextResponse;
9
use Psr\Http\Message\ResponseInterface;
10
use Psr\Http\Message\ServerRequestInterface;
11
12
class DownloadCounter extends AbstractHandler
13
{
14
    public function handle(ServerRequestInterface $request): ResponseInterface
15
    {
16
        $path = DownloadFile::COUNTER_PATH;
17
        if (!is_readable($path)) {
18
            return $this->createError('File not found on disk, or not readable');
19
        }
20
21
        $response = new TextResponse(file_get_contents($path));
22
23
        return $response;
24
    }
25
}
26