mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-05 23:03:11 +08:00
33 lines
785 B
PHP
33 lines
785 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Shlinkio\Shlink\Core\Visit;
|
|
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
use Shlinkio\Shlink\Core\Entity\Visit;
|
|
use Shlinkio\Shlink\Core\Repository\VisitRepository;
|
|
use Shlinkio\Shlink\Core\Visit\Model\VisitsStats;
|
|
|
|
class VisitsStatsHelper implements VisitsStatsHelperInterface
|
|
{
|
|
private EntityManagerInterface $em;
|
|
|
|
public function __construct(EntityManagerInterface $em)
|
|
{
|
|
$this->em = $em;
|
|
}
|
|
|
|
public function getVisitsStats(): VisitsStats
|
|
{
|
|
return new VisitsStats($this->getVisitsCount());
|
|
}
|
|
|
|
private function getVisitsCount(): int
|
|
{
|
|
/** @var VisitRepository $visitsRepo */
|
|
$visitsRepo = $this->em->getRepository(Visit::class);
|
|
return $visitsRepo->count([]);
|
|
}
|
|
}
|