Completed
Push — develop ( 449838...84b38c )
by Alejandro
16s queued 12s
created

GlobalVisitsAction   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 4 1
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Shlinkio\Shlink\Rest\Action\Visit;
6
7
use Laminas\Diactoros\Response\JsonResponse;
8
use Psr\Http\Message\ResponseInterface;
9
use Psr\Http\Message\ServerRequestInterface;
10
use Shlinkio\Shlink\Core\Visit\VisitsStatsHelperInterface;
11
use Shlinkio\Shlink\Rest\Action\AbstractRestAction;
12
13
class GlobalVisitsAction extends AbstractRestAction
14
{
15
    protected const ROUTE_PATH = '/visits';
16
    protected const ROUTE_ALLOWED_METHODS = [self::METHOD_GET];
17
18
    private VisitsStatsHelperInterface $statsHelper;
19
20 1
    public function __construct(VisitsStatsHelperInterface $statsHelper)
21
    {
22 1
        $this->statsHelper = $statsHelper;
23
    }
24
25 1
    public function handle(ServerRequestInterface $request): ResponseInterface
26
    {
27 1
        return new JsonResponse([
28 1
            'visits' => $this->statsHelper->getVisitsStats(),
29
        ]);
30
    }
31
}
32