Replace method calls.

This commit is contained in:
James Cole
2025-09-10 16:07:19 +02:00
parent a3674c4dfe
commit cb0b42e44b
51 changed files with 87 additions and 91 deletions

View File

@@ -28,6 +28,7 @@ use Carbon\Carbon;
use FireflyIII\Enums\RecurrenceRepetitionWeekend;
use FireflyIII\Models\RecurrenceRepetition;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
/**
* Trait FiltersWeekends
@@ -39,9 +40,9 @@ trait FiltersWeekends
*/
protected function filterWeekends(RecurrenceRepetition $repetition, array $dates): array
{
app('log')->debug(sprintf('Now in %s', __METHOD__));
Log::debug(sprintf('Now in %s', __METHOD__));
if (RecurrenceRepetitionWeekend::WEEKEND_DO_NOTHING->value === $repetition->weekend) {
app('log')->debug('Repetition will not be filtered on weekend days.');
Log::debug('Repetition will not be filtered on weekend days.');
return $dates;
}
@@ -53,7 +54,7 @@ trait FiltersWeekends
if (!$isWeekend) {
$return[] = clone $date;
// app('log')->debug(sprintf('Date is %s, not a weekend date.', $date->format('D d M Y')));
// Log::debug(sprintf('Date is %s, not a weekend date.', $date->format('D d M Y')));
continue;
}
@@ -61,7 +62,7 @@ trait FiltersWeekends
if (RecurrenceRepetitionWeekend::WEEKEND_TO_FRIDAY->value === $repetition->weekend) {
$clone = clone $date;
$clone->addDays(5 - $date->dayOfWeekIso);
app('log')->debug(
Log::debug(
sprintf('Date is %s, and this is in the weekend, so corrected to %s (Friday).', $date->format('D d M Y'), $clone->format('D d M Y'))
);
$return[] = clone $clone;
@@ -73,23 +74,23 @@ trait FiltersWeekends
if (RecurrenceRepetitionWeekend::WEEKEND_TO_MONDAY->value === $repetition->weekend) {
$clone = clone $date;
$clone->addDays(8 - $date->dayOfWeekIso);
app('log')->debug(
Log::debug(
sprintf('Date is %s, and this is in the weekend, so corrected to %s (Monday).', $date->format('D d M Y'), $clone->format('D d M Y'))
);
$return[] = $clone;
continue;
}
// app('log')->debug(sprintf('Date is %s, removed from final result', $date->format('D d M Y')));
// Log::debug(sprintf('Date is %s, removed from final result', $date->format('D d M Y')));
}
// filter unique dates
app('log')->debug(sprintf('Count before filtering: %d', count($dates)));
Log::debug(sprintf('Count before filtering: %d', count($dates)));
$collection = new Collection($return);
$filtered = $collection->unique();
$return = $filtered->toArray();
app('log')->debug(sprintf('Count after filtering: %d', count($return)));
Log::debug(sprintf('Count after filtering: %d', count($return)));
return $return;
}