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

VisitsStatsHelper::getVisitsCount()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Shlinkio\Shlink\Core\Visit;
6
7
use Doctrine\ORM\EntityManagerInterface;
8
use Shlinkio\Shlink\Core\Entity\Visit;
9
use Shlinkio\Shlink\Core\Repository\VisitRepository;
10
use Shlinkio\Shlink\Core\Visit\Model\VisitsStats;
11
12
class VisitsStatsHelper implements VisitsStatsHelperInterface
13
{
14
    private EntityManagerInterface $em;
15
16 11
    public function __construct(EntityManagerInterface $em)
17
    {
18 11
        $this->em = $em;
19
    }
20
21 11
    public function getVisitsStats(): VisitsStats
22
    {
23 11
        return new VisitsStats($this->getVisitsCount());
24
    }
25
26 11
    private function getVisitsCount(): int
27
    {
28
        /** @var VisitRepository $visitsRepo */
29 11
        $visitsRepo = $this->em->getRepository(Visit::class);
30 11
        return $visitsRepo->count([]);
31
    }
32
}
33