mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-06 23:33:13 +08:00
Migrated all constructor props to property promotion when possible
This commit is contained in:
@@ -8,13 +8,8 @@ use JsonSerializable;
|
||||
|
||||
final class VisitsStats implements JsonSerializable
|
||||
{
|
||||
private int $visitsCount;
|
||||
private int $orphanVisitsCount;
|
||||
|
||||
public function __construct(int $visitsCount, int $orphanVisitsCount)
|
||||
public function __construct(private int $visitsCount, private int $orphanVisitsCount)
|
||||
{
|
||||
$this->visitsCount = $visitsCount;
|
||||
$this->orphanVisitsCount = $orphanVisitsCount;
|
||||
}
|
||||
|
||||
public function jsonSerialize(): array
|
||||
|
||||
@@ -9,15 +9,11 @@ use Shlinkio\Shlink\Common\Util\DateRange;
|
||||
|
||||
class VisitsCountFiltering
|
||||
{
|
||||
private ?DateRange $dateRange;
|
||||
private bool $excludeBots;
|
||||
private ?Specification $spec;
|
||||
|
||||
public function __construct(?DateRange $dateRange = null, bool $excludeBots = false, ?Specification $spec = null)
|
||||
{
|
||||
$this->dateRange = $dateRange;
|
||||
$this->excludeBots = $excludeBots;
|
||||
$this->spec = $spec;
|
||||
public function __construct(
|
||||
private ?DateRange $dateRange = null,
|
||||
private bool $excludeBots = false,
|
||||
private ?Specification $spec = null
|
||||
) {
|
||||
}
|
||||
|
||||
public function dateRange(): ?DateRange
|
||||
|
||||
@@ -9,19 +9,14 @@ use Shlinkio\Shlink\Common\Util\DateRange;
|
||||
|
||||
final class VisitsListFiltering extends VisitsCountFiltering
|
||||
{
|
||||
private ?int $limit;
|
||||
private ?int $offset;
|
||||
|
||||
public function __construct(
|
||||
?DateRange $dateRange = null,
|
||||
bool $excludeBots = false,
|
||||
?Specification $spec = null,
|
||||
?int $limit = null,
|
||||
?int $offset = null
|
||||
private ?int $limit = null,
|
||||
private ?int $offset = null
|
||||
) {
|
||||
parent::__construct($dateRange, $excludeBots, $spec);
|
||||
$this->limit = $limit;
|
||||
$this->offset = $offset;
|
||||
}
|
||||
|
||||
public function limit(): ?int
|
||||
|
||||
@@ -12,12 +12,9 @@ use Shlinkio\Shlink\Core\Visit\Persistence\VisitsCountFiltering;
|
||||
|
||||
class CountOfOrphanVisits extends BaseSpecification
|
||||
{
|
||||
private VisitsCountFiltering $filtering;
|
||||
|
||||
public function __construct(VisitsCountFiltering $filtering)
|
||||
public function __construct(private VisitsCountFiltering $filtering)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->filtering = $filtering;
|
||||
}
|
||||
|
||||
protected function getSpec(): Specification
|
||||
|
||||
@@ -12,12 +12,9 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
|
||||
|
||||
class CountOfShortUrlVisits extends BaseSpecification
|
||||
{
|
||||
private ?ApiKey $apiKey;
|
||||
|
||||
public function __construct(?ApiKey $apiKey)
|
||||
public function __construct(private ?ApiKey $apiKey)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->apiKey = $apiKey;
|
||||
}
|
||||
|
||||
protected function getSpec(): Specification
|
||||
|
||||
@@ -13,13 +13,10 @@ use Shlinkio\Shlink\IpGeolocation\Model\Location;
|
||||
|
||||
class VisitLocator implements VisitLocatorInterface
|
||||
{
|
||||
private EntityManagerInterface $em;
|
||||
private VisitRepositoryInterface $repo;
|
||||
|
||||
public function __construct(EntityManagerInterface $em)
|
||||
public function __construct(private EntityManagerInterface $em)
|
||||
{
|
||||
$this->em = $em;
|
||||
|
||||
/** @var VisitRepositoryInterface $repo */
|
||||
$repo = $em->getRepository(Visit::class);
|
||||
$this->repo = $repo;
|
||||
|
||||
@@ -27,11 +27,8 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
|
||||
|
||||
class VisitsStatsHelper implements VisitsStatsHelperInterface
|
||||
{
|
||||
private EntityManagerInterface $em;
|
||||
|
||||
public function __construct(EntityManagerInterface $em)
|
||||
public function __construct(private EntityManagerInterface $em)
|
||||
{
|
||||
$this->em = $em;
|
||||
}
|
||||
|
||||
public function getVisitsStats(?ApiKey $apiKey = null): VisitsStats
|
||||
|
||||
@@ -14,18 +14,11 @@ use Shlinkio\Shlink\Core\Options\TrackingOptions;
|
||||
|
||||
class VisitsTracker implements VisitsTrackerInterface
|
||||
{
|
||||
private ORM\EntityManagerInterface $em;
|
||||
private EventDispatcherInterface $eventDispatcher;
|
||||
private TrackingOptions $options;
|
||||
|
||||
public function __construct(
|
||||
ORM\EntityManagerInterface $em,
|
||||
EventDispatcherInterface $eventDispatcher,
|
||||
TrackingOptions $options
|
||||
private ORM\EntityManagerInterface $em,
|
||||
private EventDispatcherInterface $eventDispatcher,
|
||||
private TrackingOptions $options
|
||||
) {
|
||||
$this->em = $em;
|
||||
$this->eventDispatcher = $eventDispatcher;
|
||||
$this->options = $options;
|
||||
}
|
||||
|
||||
public function track(ShortUrl $shortUrl, Visitor $visitor): void
|
||||
|
||||
Reference in New Issue
Block a user