Code cleanup.

This commit is contained in:
James Cole
2023-12-20 19:35:52 +01:00
parent c4f6366642
commit 64ec0cf62e
997 changed files with 12908 additions and 28136 deletions

View File

@@ -32,57 +32,34 @@ use FireflyIII\Helpers\Collector\GroupCollectorInterface;
*/
trait TimeCollection
{
/**
* @param string $day
*
* @return GroupCollectorInterface
*/
public function dayAfter(string $day): GroupCollectorInterface
{
$this->query->whereDay('transaction_journals.date', '>=', $day);
return $this;
}
/**
* @param string $day
*
* @return GroupCollectorInterface
*/
public function dayBefore(string $day): GroupCollectorInterface
{
$this->query->whereDay('transaction_journals.date', '<=', $day);
return $this;
}
/**
* @param string $day
*
* @return GroupCollectorInterface
*/
public function dayIs(string $day): GroupCollectorInterface
{
$this->query->whereDay('transaction_journals.date', '=', $day);
return $this;
}
/**
* @param string $day
*
* @return GroupCollectorInterface
*/
public function dayIsNot(string $day): GroupCollectorInterface
{
$this->query->whereDay('transaction_journals.date', '!=', $day);
return $this;
}
/**
* @param Carbon $start
* @param Carbon $end
* @param string $field
*
* @return GroupCollectorInterface
*/
public function excludeMetaDateRange(Carbon $start, Carbon $end, string $field): GroupCollectorInterface
{
if ($end < $start) {
@@ -107,9 +84,6 @@ trait TimeCollection
return $this;
}
/**
* @inheritDoc
*/
public function withMetaDate(string $field): GroupCollectorInterface
{
$this->joinMetaDataTables();
@@ -119,13 +93,6 @@ trait TimeCollection
return $this;
}
/**
* @param Carbon $start
* @param Carbon $end
* @param string $field
*
* @return GroupCollectorInterface
*/
public function excludeObjectRange(Carbon $start, Carbon $end, string $field): GroupCollectorInterface
{
$after = $start->format('Y-m-d 00:00:00');
@@ -137,12 +104,6 @@ trait TimeCollection
return $this;
}
/**
* @param Carbon $start
* @param Carbon $end
*
* @return GroupCollectorInterface
*/
public function excludeRange(Carbon $start, Carbon $end): GroupCollectorInterface
{
if ($end < $start) {
@@ -157,12 +118,6 @@ trait TimeCollection
return $this;
}
/**
* @param string $day
* @param string $field
*
* @return GroupCollectorInterface
*/
public function metaDayAfter(string $day, string $field): GroupCollectorInterface
{
$this->withMetaDate($field);
@@ -181,12 +136,6 @@ trait TimeCollection
return $this;
}
/**
* @param string $day
* @param string $field
*
* @return GroupCollectorInterface
*/
public function metaDayBefore(string $day, string $field): GroupCollectorInterface
{
$this->withMetaDate($field);
@@ -205,12 +154,6 @@ trait TimeCollection
return $this;
}
/**
* @param string $day
* @param string $field
*
* @return GroupCollectorInterface
*/
public function metaDayIs(string $day, string $field): GroupCollectorInterface
{
$this->withMetaDate($field);
@@ -225,15 +168,10 @@ trait TimeCollection
return false;
};
$this->postFilters[] = $filter;
return $this;
}
/**
* @param string $day
* @param string $field
*
* @return GroupCollectorInterface
*/
public function metaDayIsNot(string $day, string $field): GroupCollectorInterface
{
$this->withMetaDate($field);
@@ -248,15 +186,10 @@ trait TimeCollection
return false;
};
$this->postFilters[] = $filter;
return $this;
}
/**
* @param string $month
* @param string $field
*
* @return GroupCollectorInterface
*/
public function metaMonthAfter(string $month, string $field): GroupCollectorInterface
{
$this->withMetaDate($field);
@@ -275,12 +208,6 @@ trait TimeCollection
return $this;
}
/**
* @param string $month
* @param string $field
*
* @return GroupCollectorInterface
*/
public function metaMonthBefore(string $month, string $field): GroupCollectorInterface
{
$this->withMetaDate($field);
@@ -299,12 +226,6 @@ trait TimeCollection
return $this;
}
/**
* @param string $month
* @param string $field
*
* @return GroupCollectorInterface
*/
public function metaMonthIs(string $month, string $field): GroupCollectorInterface
{
$this->withMetaDate($field);
@@ -319,15 +240,10 @@ trait TimeCollection
return false;
};
$this->postFilters[] = $filter;
return $this;
}
/**
* @param string $month
* @param string $field
*
* @return GroupCollectorInterface
*/
public function metaMonthIsNot(string $month, string $field): GroupCollectorInterface
{
$this->withMetaDate($field);
@@ -342,15 +258,10 @@ trait TimeCollection
return false;
};
$this->postFilters[] = $filter;
return $this;
}
/**
* @param string $year
* @param string $field
*
* @return GroupCollectorInterface
*/
public function metaYearAfter(string $year, string $field): GroupCollectorInterface
{
$this->withMetaDate($field);
@@ -369,12 +280,6 @@ trait TimeCollection
return $this;
}
/**
* @param string $year
* @param string $field
*
* @return GroupCollectorInterface
*/
public function metaYearBefore(string $year, string $field): GroupCollectorInterface
{
$this->withMetaDate($field);
@@ -393,12 +298,6 @@ trait TimeCollection
return $this;
}
/**
* @param string $year
* @param string $field
*
* @return GroupCollectorInterface
*/
public function metaYearIs(string $year, string $field): GroupCollectorInterface
{
$this->withMetaDate($field);
@@ -417,12 +316,6 @@ trait TimeCollection
return $this;
}
/**
* @param string $year
* @param string $field
*
* @return GroupCollectorInterface
*/
public function metaYearIsNot(string $year, string $field): GroupCollectorInterface
{
$this->withMetaDate($field);
@@ -433,6 +326,7 @@ trait TimeCollection
return $year !== (string)$transaction[$field]->year;
}
}
return true;
};
$this->postFilters[] = $filter;
@@ -440,200 +334,120 @@ trait TimeCollection
return $this;
}
/**
* @param string $month
*
* @return GroupCollectorInterface
*/
public function monthAfter(string $month): GroupCollectorInterface
{
$this->query->whereMonth('transaction_journals.date', '>=', $month);
return $this;
}
/**
* @param string $month
*
* @return GroupCollectorInterface
*/
public function monthBefore(string $month): GroupCollectorInterface
{
$this->query->whereMonth('transaction_journals.date', '<=', $month);
return $this;
}
/**
* @param string $month
*
* @return GroupCollectorInterface
*/
public function monthIs(string $month): GroupCollectorInterface
{
$this->query->whereMonth('transaction_journals.date', '=', $month);
return $this;
}
/**
* @param string $month
*
* @return GroupCollectorInterface
*/
public function monthIsNot(string $month): GroupCollectorInterface
{
$this->query->whereMonth('transaction_journals.date', '!=', $month);
return $this;
}
/**
* @param string $day
* @param string $field
*
* @return GroupCollectorInterface
*/
public function objectDayAfter(string $day, string $field): GroupCollectorInterface
{
$this->query->whereDay(sprintf('transaction_journals.%s', $field), '>=', $day);
return $this;
}
/**
* @param string $day
* @param string $field
*
* @return GroupCollectorInterface
*/
public function objectDayBefore(string $day, string $field): GroupCollectorInterface
{
$this->query->whereDay(sprintf('transaction_journals.%s', $field), '<=', $day);
return $this;
}
/**
* @param string $day
* @param string $field
*
* @return GroupCollectorInterface
*/
public function objectDayIs(string $day, string $field): GroupCollectorInterface
{
$this->query->whereDay(sprintf('transaction_journals.%s', $field), '=', $day);
return $this;
}
/**
* @param string $day
* @param string $field
*
* @return GroupCollectorInterface
*/
public function objectDayIsNot(string $day, string $field): GroupCollectorInterface
{
$this->query->whereDay(sprintf('transaction_journals.%s', $field), '!=', $day);
return $this;
}
/**
* @param string $month
* @param string $field
*
* @return GroupCollectorInterface
*/
public function objectMonthAfter(string $month, string $field): GroupCollectorInterface
{
$this->query->whereMonth(sprintf('transaction_journals.%s', $field), '>=', $month);
return $this;
}
/**
* @param string $month
* @param string $field
*
* @return GroupCollectorInterface
*/
public function objectMonthBefore(string $month, string $field): GroupCollectorInterface
{
$this->query->whereMonth(sprintf('transaction_journals.%s', $field), '<=', $month);
return $this;
}
/**
* @param string $month
* @param string $field
*
* @return GroupCollectorInterface
*/
public function objectMonthIs(string $month, string $field): GroupCollectorInterface
{
$this->query->whereMonth(sprintf('transaction_journals.%s', $field), '=', $month);
return $this;
}
/**
* @param string $month
* @param string $field
*
* @return GroupCollectorInterface
*/
public function objectMonthIsNot(string $month, string $field): GroupCollectorInterface
{
$this->query->whereMonth(sprintf('transaction_journals.%s', $field), '!=', $month);
return $this;
}
/**
* @param string $year
* @param string $field
*
* @return GroupCollectorInterface
*/
public function objectYearAfter(string $year, string $field): GroupCollectorInterface
{
$this->query->whereYear(sprintf('transaction_journals.%s', $field), '>=', $year);
return $this;
}
/**
* @param string $year
* @param string $field
*
* @return GroupCollectorInterface
*/
public function objectYearBefore(string $year, string $field): GroupCollectorInterface
{
$this->query->whereYear(sprintf('transaction_journals.%s', $field), '<=', $year);
return $this;
}
/**
* @param string $year
* @param string $field
*
* @return GroupCollectorInterface
*/
public function objectYearIs(string $year, string $field): GroupCollectorInterface
{
$this->query->whereYear(sprintf('transaction_journals.%s', $field), '=', $year);
return $this;
}
/**
* @param string $year
* @param string $field
*
* @return GroupCollectorInterface
*/
public function objectYearIsNot(string $year, string $field): GroupCollectorInterface
{
$this->query->whereYear(sprintf('transaction_journals.%s', $field), '!=', $year);
return $this;
}
/**
* Collect transactions after a specific date.
*
* @param Carbon $date
*
* @return GroupCollectorInterface
*/
public function setAfter(Carbon $date): GroupCollectorInterface
{
@@ -645,10 +459,6 @@ trait TimeCollection
/**
* Collect transactions before a specific date.
*
* @param Carbon $date
*
* @return GroupCollectorInterface
*/
public function setBefore(Carbon $date): GroupCollectorInterface
{
@@ -660,10 +470,6 @@ trait TimeCollection
/**
* Collect transactions created on a specific date.
*
* @param Carbon $date
*
* @return GroupCollectorInterface
*/
public function setCreatedAt(Carbon $date): GroupCollectorInterface
{
@@ -677,10 +483,6 @@ trait TimeCollection
/**
* Set the end time of the results to return.
*
* @param Carbon $end
*
* @return GroupCollectorInterface
*/
public function setEnd(Carbon $end): GroupCollectorInterface
{
@@ -692,12 +494,6 @@ trait TimeCollection
return $this;
}
/**
* @param Carbon $date
* @param string $field
*
* @return GroupCollectorInterface
*/
public function setMetaAfter(Carbon $date, string $field): GroupCollectorInterface
{
$this->withMetaDate($field);
@@ -717,12 +513,6 @@ trait TimeCollection
return $this;
}
/**
* @param Carbon $date
* @param string $field
*
* @return GroupCollectorInterface
*/
public function setMetaBefore(Carbon $date, string $field): GroupCollectorInterface
{
$this->withMetaDate($field);
@@ -741,13 +531,6 @@ trait TimeCollection
return $this;
}
/**
* @param Carbon $start
* @param Carbon $end
* @param string $field
*
* @return GroupCollectorInterface
*/
public function setMetaDateRange(Carbon $start, Carbon $end, string $field): GroupCollectorInterface
{
if ($end < $start) {
@@ -769,15 +552,10 @@ trait TimeCollection
return false;
};
$this->postFilters[] = $filter;
return $this;
}
/**
* @param Carbon $date
* @param string $field
*
* @return GroupCollectorInterface
*/
public function setObjectAfter(Carbon $date, string $field): GroupCollectorInterface
{
$afterStr = $date->format('Y-m-d 00:00:00');
@@ -786,26 +564,14 @@ trait TimeCollection
return $this;
}
/**
* @param Carbon $date
* @param string $field
*
* @return GroupCollectorInterface
*/
public function setObjectBefore(Carbon $date, string $field): GroupCollectorInterface
{
$afterStr = $date->format('Y-m-d 00:00:00');
$this->query->where(sprintf('transaction_journals.%s', $field), '<=', $afterStr);
return $this;
}
/**
* @param Carbon $start
* @param Carbon $end
* @param string $field
*
* @return GroupCollectorInterface
*/
public function setObjectRange(Carbon $start, Carbon $end, string $field): GroupCollectorInterface
{
$after = $start->format('Y-m-d 00:00:00');
@@ -820,11 +586,6 @@ trait TimeCollection
* Set the start and end time of the results to return.
*
* Can either or both be NULL
*
* @param Carbon|null $start
* @param Carbon|null $end
*
* @return GroupCollectorInterface
*/
public function setRange(?Carbon $start, ?Carbon $end): GroupCollectorInterface
{
@@ -847,10 +608,6 @@ trait TimeCollection
/**
* Set the start time of the results to return.
*
* @param Carbon $start
*
* @return GroupCollectorInterface
*/
public function setStart(Carbon $start): GroupCollectorInterface
{
@@ -863,10 +620,6 @@ trait TimeCollection
/**
* Collect transactions updated on a specific date.
*
* @param Carbon $date
*
* @return GroupCollectorInterface
*/
public function setUpdatedAt(Carbon $date): GroupCollectorInterface
{
@@ -878,47 +631,31 @@ trait TimeCollection
return $this;
}
/**
* @param string $year
*
* @return GroupCollectorInterface
*/
public function yearAfter(string $year): GroupCollectorInterface
{
$this->query->whereYear('transaction_journals.date', '>=', $year);
return $this;
}
/**
* @param string $year
*
* @return GroupCollectorInterface
*/
public function yearBefore(string $year): GroupCollectorInterface
{
$this->query->whereYear('transaction_journals.date', '<=', $year);
return $this;
}
/**
* @param string $year
*
* @return GroupCollectorInterface
*/
public function yearIs(string $year): GroupCollectorInterface
{
$this->query->whereYear('transaction_journals.date', '=', $year);
return $this;
}
/**
* @param string $year
*
* @return GroupCollectorInterface
*/
public function yearIsNot(string $year): GroupCollectorInterface
{
$this->query->whereYear('transaction_journals.date', '!=', $year);
return $this;
}
}