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.
Completed
Push — master ( eac42d...55bb68 )
by François
02:33
created

UiModule::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 3
1
<?php
2
3
/**
4
 *  This program is free software: you can redistribute it and/or modify
5
 *  it under the terms of the GNU Lesser General Public License as published by
6
 *  the Free Software Foundation, either version 3 of the License, or
7
 *  (at your option) any later version.
8
 *
9
 *  This program is distributed in the hope that it will be useful,
10
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 *  GNU Lesser General Public License for more details.
13
 *
14
 *  You should have received a copy of the GNU Lesser General Public License
15
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
 */
17
18
namespace fkooman\RemoteStorage;
19
20
use fkooman\RemoteStorage\Http\HtmlResponse;
21
use fkooman\RemoteStorage\Http\RedirectResponse;
22
use fkooman\RemoteStorage\Http\Request;
23
use fkooman\RemoteStorage\OAuth\TokenStorage;
24
25
class UiModule
26
{
27
    private $remoteStorage;
28
29
    /** @var TplInterface */
30
    private $tpl;
31
32
    /** @var \fkooman\RemoteStorage\OAuth\TokenStorage */
33
    private $tokenStorage;
34
35
    public function __construct(RemoteStorage $remoteStorage, TplInterface $tpl, TokenStorage $tokenStorage)
36
    {
37
        $this->remoteStorage = $remoteStorage;
38
        $this->tpl = $tpl;
39
        $this->tokenStorage = $tokenStorage;
40
    }
41
42
    /**
43
     * @param Request      $request
44
     * @param string|false $userId
45
     */
46
    public function getRootPage(Request $request, $userId)
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
47
    {
48
        return new HtmlResponse(
49
            $this->tpl->render(
50
                'indexPage',
51
                [
52
                    'user_id' => $userId,
53
                    'show_account_icon' => true,
54
                ]
55
            )
56
        );
57
    }
58
59
    /**
60
     * @param Request $request
61
     * @param string  $userId
62
     */
63
    public function getAccountPage(Request $request, $userId)
64
    {
65
        $approvalList = $this->tokenStorage->getAuthorizedClients($userId);
66
67
        return new HtmlResponse(
68
            $this->tpl->render(
69
                'getAccountPage',
70
                [
71
                    'approval_list' => $approvalList,
72
                    'host' => $request->getServerName(),
73
                    'user_id' => $userId,
74
                    'disk_usage' => $this->remoteStorage->getFolderSize(new Path('/'.$userId.'/')),
75
                    'request_url' => $request->getUri(),
76
                    'show_account_icon' => true,
77
                ]
78
            )
79
        );
80
    }
81
82
    /**
83
     * @param Request $request
84
     * @param string  $userId
85
     */
86
    public function postAccountPage(Request $request, $userId)
87
    {
88
        // XXX InputValidation
89
        $clientId = $request->getPostParameter('client_id');
90
        $this->tokenStorage->removeClientTokens($userId, $clientId);
91
92
        return new RedirectResponse($request->getUri(), 302);
93
    }
94
}
95