GetStreakStatistics
in package
Calculates current streak, best streak, and total active days.
A streak is a run of consecutive calendar days with any activity. The current streak only counts if the most recent active day is today or yesterday.
Tags
Table of Contents
Properties
Methods
- __construct() : mixed
- Constructor.
- execute() : StreakResult
- Execute the use case.
- countConsecutiveFromStart() : int
- Count consecutive days starting from the first date in the list.
Properties
$repository
private
ActivityRepositoryInterface
$repository
Methods
__construct()
Constructor.
public
__construct(ActivityRepositoryInterface $repository) : mixed
Parameters
- $repository : ActivityRepositoryInterface
-
Activity repository
execute()
Execute the use case.
public
execute() : StreakResult
Return values
StreakResult —Streak statistics
countConsecutiveFromStart()
Count consecutive days starting from the first date in the list.
private
countConsecutiveFromStart(array<int, string> $dates, DateTimeImmutable $firstDate) : int
Parameters
- $dates : array<int, string>
-
Dates descending
- $firstDate : DateTimeImmutable
-
The most recent date
Return values
int —Consecutive day count