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

DownloadCounter::handle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 10
ccs 0
cts 6
cp 0
rs 10
cc 2
nc 2
nop 1
crap 6
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