Migrated all constructor props to property promotion when possible

This commit is contained in:
Alejandro Celaya
2021-05-23 11:57:31 +02:00
parent 4b5fa6ddad
commit e0f0bb5523
118 changed files with 237 additions and 713 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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;

View File

@@ -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

View File

@@ -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