Function no longer returns nulls.

This commit is contained in:
James Cole 2020-08-02 12:14:56 +02:00
parent e7e21348eb
commit d0a01d73c4
No known key found for this signature in database
GPG Key ID: B5669F9493CDE38D

View File

@ -214,7 +214,7 @@ class BudgetController extends Controller
$return = [];
/** @var array|null $arr */
foreach ($expenses as $arr) {
if (null !== $arr) {
if ([] !== $arr) {
$return[] = $arr;
}
}
@ -263,9 +263,9 @@ class BudgetController extends Controller
/**
* @param BudgetLimit $limit
*
* @return array|null
* @return array
*/
private function getExpensesForLimit(BudgetLimit $limit): ?array
private function getExpensesForLimit(BudgetLimit $limit): array
{
$budget = $limit->budget;
$spent = $this->opsRepository->sumExpenses($limit->start_date, $limit->end_date, null, new Collection([$budget]), $limit->transactionCurrency);
@ -273,7 +273,7 @@ class BudgetController extends Controller
// when limited to a currency, the count is always one. Or it's empty.
$set = array_shift($spent);
if (null === $set) {
return null;
return [];
}
$return = [
'label' => sprintf('%s (%s)', $budget->name, $set['currency_name']),