mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-05 20:22:07 +00:00
Code clean up.
This commit is contained in:
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Repositories\Budget;
|
||||
@@ -42,9 +41,7 @@ use Navigation;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* Class BudgetRepository
|
||||
*
|
||||
* @package FireflyIII\Repositories\Budget
|
||||
* Class BudgetRepository.
|
||||
*/
|
||||
class BudgetRepository implements BudgetRepositoryInterface
|
||||
{
|
||||
@@ -133,7 +130,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters entries from the result set generated by getBudgetPeriodReport
|
||||
* Filters entries from the result set generated by getBudgetPeriodReport.
|
||||
*
|
||||
* @param Collection $set
|
||||
* @param int $budgetId
|
||||
@@ -155,7 +152,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
}
|
||||
);
|
||||
$amount = '0';
|
||||
if (!is_null($result->first())) {
|
||||
if (null !== $result->first()) {
|
||||
$amount = $result->first()->sum_of_period;
|
||||
}
|
||||
|
||||
@@ -175,7 +172,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
public function find(int $budgetId): Budget
|
||||
{
|
||||
$budget = $this->user->budgets()->find($budgetId);
|
||||
if (is_null($budget)) {
|
||||
if (null === $budget) {
|
||||
$budget = new Budget;
|
||||
}
|
||||
|
||||
@@ -214,7 +211,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
{
|
||||
$oldest = Carbon::create()->startOfYear();
|
||||
$journal = $budget->transactionJournals()->orderBy('date', 'ASC')->first();
|
||||
if (!is_null($journal)) {
|
||||
if (null !== $journal) {
|
||||
$oldest = $journal->date < $oldest ? $journal->date : $oldest;
|
||||
}
|
||||
|
||||
@@ -222,7 +219,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
->transactions()
|
||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.id')
|
||||
->orderBy('transaction_journals.date', 'ASC')->first(['transactions.*', 'transaction_journals.date']);
|
||||
if (!is_null($transaction)) {
|
||||
if (null !== $transaction) {
|
||||
$carbon = new Carbon($transaction->date);
|
||||
$oldest = $carbon < $oldest ? $carbon : $oldest;
|
||||
}
|
||||
@@ -303,7 +300,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
->where('transaction_currency_id', $currency->id)
|
||||
->where('start_date', $start->format('Y-m-d'))
|
||||
->where('end_date', $end->format('Y-m-d'))->first();
|
||||
if (!is_null($availableBudget)) {
|
||||
if (null !== $availableBudget) {
|
||||
$amount = strval($availableBudget->amount);
|
||||
}
|
||||
|
||||
@@ -478,7 +475,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
->where('transaction_currency_id', $currency->id)
|
||||
->where('start_date', $start->format('Y-m-d'))
|
||||
->where('end_date', $end->format('Y-m-d'))->first();
|
||||
if (is_null($availableBudget)) {
|
||||
if (null === $availableBudget) {
|
||||
$availableBudget = new AvailableBudget;
|
||||
$availableBudget->user()->associate($this->user);
|
||||
$availableBudget->transactionCurrency()->associate($currency);
|
||||
@@ -517,7 +514,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
if ($accounts->count() > 0) {
|
||||
$collector->setAccounts($accounts);
|
||||
}
|
||||
if ($accounts->count() === 0) {
|
||||
if (0 === $accounts->count()) {
|
||||
$collector->setAllAssetAccounts();
|
||||
}
|
||||
|
||||
@@ -544,7 +541,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
if ($accounts->count() > 0) {
|
||||
$collector->setAccounts($accounts);
|
||||
}
|
||||
if ($accounts->count() === 0) {
|
||||
if (0 === $accounts->count()) {
|
||||
$collector->setAllAssetAccounts();
|
||||
}
|
||||
|
||||
@@ -621,7 +618,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
->first(['budget_limits.*']);
|
||||
|
||||
// if more than 1 limit found, delete the others:
|
||||
if ($limits > 1 && !is_null($limit)) {
|
||||
if ($limits > 1 && null !== $limit) {
|
||||
$budget->budgetlimits()
|
||||
->where('budget_limits.start_date', $start->format('Y-m-d'))
|
||||
->where('budget_limits.end_date', $end->format('Y-m-d'))
|
||||
@@ -629,13 +626,13 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
}
|
||||
|
||||
// delete if amount is zero.
|
||||
if (!is_null($limit) && $amount <= 0.0) {
|
||||
if (null !== $limit && $amount <= 0.0) {
|
||||
$limit->delete();
|
||||
|
||||
return new BudgetLimit;
|
||||
}
|
||||
// update if exists:
|
||||
if (!is_null($limit)) {
|
||||
if (null !== $limit) {
|
||||
$limit->amount = $amount;
|
||||
$limit->save();
|
||||
|
||||
|
Reference in New Issue
Block a user