GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( a70b7c...7d482a )
by James
21:49 queued 11:38
created

Http/Controllers/Category/NoCategoryController.php (2 issues)

1
<?php
2
/**
3
 * NoCategoryController.php
4
 * Copyright (c) 2018 [email protected]
5
 *
6
 * This file is part of Firefly III.
7
 *
8
 * Firefly III is free software: you can redistribute it and/or modify
9
 * it under the terms of the GNU General Public License as published by
10
 * the Free Software Foundation, either version 3 of the License, or
11
 * (at your option) any later version.
12
 *
13
 * Firefly III is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
20
 */
21
22
declare(strict_types=1);
23
24
namespace FireflyIII\Http\Controllers\Category;
25
26
27
use Carbon\Carbon;
28
use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
29
use FireflyIII\Helpers\Filter\InternalTransferFilter;
30
use FireflyIII\Http\Controllers\Controller;
31
use FireflyIII\Models\TransactionType;
32
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
33
use FireflyIII\Support\Http\Controllers\PeriodOverview;
34
use Illuminate\Http\Request;
35
use Illuminate\Support\Collection;
36
use Log;
37
38
/**
39
 *
40
 * Class NoCategoryController
41
 */
42
class NoCategoryController extends Controller
43
{
44
    use PeriodOverview;
45
    /** @var JournalRepositoryInterface Journals and transactions overview */
46
    private $journalRepos;
47
48
    /**
49
     * CategoryController constructor.
50
     */
51
    public function __construct()
52
    {
53
        parent::__construct();
54
55
        $this->middleware(
56
            function ($request, $next) {
57
                app('view')->share('title', (string)trans('firefly.categories'));
58
                app('view')->share('mainTitleIcon', 'fa-bar-chart');
59
                $this->journalRepos = app(JournalRepositoryInterface::class);
60
61
                return $next($request);
62
            }
63
        );
64
    }
65
66
    /**
67
     * Show transactions without a category.
68
     *
69
     * @param Request     $request
70
     * @param Carbon|null $start
71
     * @param Carbon|null $end
72
     *
73
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
74
     */
75
    public function show(Request $request, Carbon $start = null, Carbon $end = null)
76
    {
77
        Log::debug('Start of noCategory()');
78
        /** @var Carbon $start */
79
        $start = $start ?? session('start');
80
        /** @var Carbon $end */
81
        $end      = $end ?? session('end');
82
        $page     = (int)$request->get('page');
83
        $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
84
        $subTitle = trans(
85
            'firefly.without_category_between',
86
            ['start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)]
87
        );
88
        $periods  = $this->getNoCategoryPeriodOverview($start);
89
90
        Log::debug(sprintf('Start for noCategory() is %s', $start->format('Y-m-d')));
91
        Log::debug(sprintf('End for noCategory() is %s', $end->format('Y-m-d')));
92
93
        /** @var TransactionCollectorInterface $collector */
94
        $collector = app(TransactionCollectorInterface::class);
95
        $collector->setAllAssetAccounts()->setRange($start, $end)->setLimit($pageSize)->setPage($page)->withoutCategory()->withOpposingAccount()
96
                  ->setTypes([TransactionType::WITHDRAWAL, TransactionType::DEPOSIT, TransactionType::TRANSFER]);
97
        $collector->removeFilter(InternalTransferFilter::class);
98
        $transactions = $collector->getPaginatedTransactions();
99
        $transactions->setPath(route('categories.no-category'));
100
101
        return view('categories.no-category', compact('transactions', 'subTitle', 'periods', 'start', 'end'));
102
    }
103
104
105
    /**
106
     * Show all transactions without a category.
107
     *
108
     * @param Request $request
109
     *
110
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
111
     */
112
    public function showAll(Request $request)
113
    {
114
        // default values:
115
        $start    = null;
0 ignored issues
show
The assignment to $start is dead and can be removed.
Loading history...
116
        $end      = null;
0 ignored issues
show
The assignment to $end is dead and can be removed.
Loading history...
117
        $periods  = new Collection;
118
        $page     = (int)$request->get('page');
119
        $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
120
        Log::debug('Start of noCategory()');
121
        $subTitle = (string)trans('firefly.all_journals_without_category');
122
        $first    = $this->journalRepos->firstNull();
123
        $start    = null === $first ? new Carbon : $first->date;
124
        $end      = new Carbon;
125
        Log::debug(sprintf('Start for noCategory() is %s', $start->format('Y-m-d')));
126
        Log::debug(sprintf('End for noCategory() is %s', $end->format('Y-m-d')));
127
128
        /** @var TransactionCollectorInterface $collector */
129
        $collector = app(TransactionCollectorInterface::class);
130
        $collector->setAllAssetAccounts()->setRange($start, $end)->setLimit($pageSize)->setPage($page)->withoutCategory()->withOpposingAccount()
131
                  ->setTypes([TransactionType::WITHDRAWAL, TransactionType::DEPOSIT, TransactionType::TRANSFER]);
132
        $collector->removeFilter(InternalTransferFilter::class);
133
        $transactions = $collector->getPaginatedTransactions();
134
        $transactions->setPath(route('categories.no-category.all'));
135
136
        return view('categories.no-category', compact('transactions', 'subTitle', 'periods', 'start', 'end'));
137
    }
138
}
139