mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-18 12:28:46 +00:00
Update find methods to return null
This commit is contained in:
@@ -194,9 +194,9 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return Budget
|
||||
* @return Budget|null
|
||||
*/
|
||||
public function findByName(string $name): Budget
|
||||
public function findByName(string $name): ?Budget
|
||||
{
|
||||
$budgets = $this->user->budgets()->get(['budgets.*']);
|
||||
/** @var Budget $budget */
|
||||
@@ -206,7 +206,19 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
}
|
||||
}
|
||||
|
||||
return new Budget;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a budget or return NULL
|
||||
*
|
||||
* @param int $budgetId
|
||||
*
|
||||
* @return Budget|null
|
||||
*/
|
||||
public function findNull(int $budgetId): ?Budget
|
||||
{
|
||||
return $this->user->budgets()->find($budgetId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -73,19 +73,29 @@ interface BudgetRepositoryInterface
|
||||
* Find a budget.
|
||||
*
|
||||
* @param int $budgetId
|
||||
* @deprecated
|
||||
*
|
||||
* @return Budget
|
||||
*/
|
||||
public function find(int $budgetId): Budget;
|
||||
|
||||
/**
|
||||
* Find a budget or return NULL
|
||||
*
|
||||
* @param int $budgetId
|
||||
*
|
||||
* @return Budget|null
|
||||
*/
|
||||
public function findNull(int $budgetId): ?Budget;
|
||||
|
||||
/**
|
||||
* Find a budget.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return Budget
|
||||
* @return Budget|null
|
||||
*/
|
||||
public function findByName(string $name): Budget;
|
||||
public function findByName(string $name): ?Budget;
|
||||
|
||||
/**
|
||||
* This method returns the oldest journal or transaction date known to this budget.
|
||||
|
||||
Reference in New Issue
Block a user