Clean up code and comments.

This commit is contained in:
James Cole
2023-02-22 18:14:14 +01:00
parent e6dc881f56
commit e421b29b01
249 changed files with 647 additions and 1044 deletions

View File

@@ -330,6 +330,37 @@ class Navigation
return $currentEnd;
}
/**
* Returns the user's view range and if necessary, corrects the dynamic view
* range to a normal range.
* @param bool $correct
* @return string
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function getViewRange(bool $correct): string
{
$range = (string)app('preferences')->get('viewRange', '1M')?->data ?? '1M';
if (!$correct) {
return $range;
}
switch ($range) {
default:
return $range;
case 'last7':
return '1W';
case 'last30':
case 'MTD':
return '1M';
case 'last90':
case 'QTD':
return '3M';
case 'last365':
case 'YTD':
return '1Y';
}
}
/**
* @param Carbon $start
* @param Carbon $end
@@ -430,37 +461,6 @@ class Navigation
return $date->format('Y-m-d');
}
/**
* Returns the user's view range and if necessary, corrects the dynamic view
* range to a normal range.
* @param bool $correct
* @return string
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function getViewRange(bool $correct): string
{
$range = (string)app('preferences')->get('viewRange', '1M')?->data ?? '1M';
if (!$correct) {
return $range;
}
switch ($range) {
default:
return $range;
case 'last7':
return '1W';
case 'last30':
case 'MTD':
return '1M';
case 'last90':
case 'QTD':
return '3M';
case 'last365':
case 'YTD':
return '1Y';
}
}
/**
* If the date difference between start and end is less than a month, method returns trans(config.month_and_day). If the difference is less than a year,
* method returns "config.month". If the date difference is larger, method returns "config.year".