Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

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
Pull Request — master (#715)
by Alexander
03:49
created

NavigationController::mainAction()   B

Complexity

Conditions 11
Paths 33

Size

Total Lines 61
Code Lines 38

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 38
c 2
b 0
f 0
dl 0
loc 61
rs 7.3166
cc 11
nc 33
nop 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/**
3
 * (c) Kitodo. Key to digital objects e.V. <[email protected]>
4
 *
5
 * This file is part of the Kitodo and TYPO3 projects.
6
 *
7
 * @license GNU General Public License version 3 or later.
8
 * For the full copyright and license information, please read the
9
 * LICENSE.txt file that was distributed with this source code.
10
 */
11
12
namespace Kitodo\Dlf\Controller;
13
14
use Kitodo\Dlf\Common\Helper;
15
use TYPO3\CMS\Core\Utility\GeneralUtility;
16
use TYPO3\CMS\Core\Utility\MathUtility;
17
18
class NavigationController extends AbstractController
19
{
20
    /**
21
     * The main method of the plugin
22
     *
23
     * @return void
24
     */
25
    public function mainAction()
26
    {
27
        $requestData = GeneralUtility::_GPmerged('tx_dlf');
28
        unset($requestData['__referrer'], $requestData['__trustedProperties']);
29
30
        if (empty($requestData['id'])) {
31
            return '';
0 ignored issues
show
Bug Best Practice introduced by
The expression return '' returns the type string which is incompatible with the documented return type void.
Loading history...
32
        }
33
        if (empty($requestData['page'])) {
34
            $requestData['page'] = 1;
35
        }
36
        // Load current document.
37
        $this->loadDocument($requestData);
38
        if ($this->doc === null) {
39
            // Quit without doing anything if required variables are not set.
40
            return;
41
        } else {
42
            // Set default values if not set.
43
            if ($this->doc->numPages > 0) {
44
                if (!empty($requestData['logicalPage'])) {
45
                    $requestData['page'] = $this->doc->getPhysicalPage($requestData['logicalPage']);
46
                    // The logical page parameter should not appear
47
                    unset($requestData['logicalPage']);
48
                }
49
                // Set default values if not set.
50
                // $requestData['page'] may be integer or string (physical structure @ID)
51
                if (
52
                    (int) $requestData['page'] > 0
53
                    || empty($requestData['page'])
54
                ) {
55
                    $requestData['page'] = MathUtility::forceIntegerInRange((int) $requestData['page'], 1, $this->doc->numPages, 1);
56
                } else {
57
                    $requestData['page'] = array_search($requestData['page'], $this->doc->physicalStructure);
58
                }
59
                $requestData['double'] = MathUtility::forceIntegerInRange($requestData['double'], 0, 1, 0);
60
            } else {
61
                $requestData['page'] = 0;
62
                $requestData['double'] = 0;
63
            }
64
        }
65
66
        // Steps for X pages backward / forward. Double page view uses double steps.
67
        $pageSteps = $this->settings['pageStep'] * ($requestData['double'] + 1);
68
69
        $this->view->assign('page', $requestData['page']);
70
        $this->view->assign('docId', $this->doc->uid);
71
        $this->view->assign('pageId', $GLOBALS['TSFE']->id);
72
        $this->view->assign('pageSteps', $pageSteps);
73
        $this->view->assign('double', $requestData['double']);
74
        $this->view->assign('numPages', $this->doc->numPages);
75
76
        // TODO: Check if f:link.action can be used in template Navigation->main
77
        $this->view->assign('pageToList', $this->settings['targetPid']);
78
        $this->view->assign('forceAbsoluteUrl', !empty($this->conf['settings.forceAbsoluteUrl']) ? 1 : 0);
79
80
        $pageOptions = [];
81
        for ($i = 1; $i <= $this->doc->numPages; $i++) {
82
            $pageOptions[$i] = ($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$i]]['orderlabel'] ? ' - ' . htmlspecialchars($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$i]]['orderlabel']) : '');
83
        }
84
        $this->view->assign('uniqueId', uniqid(Helper::getUnqualifiedClassName(get_class($this)) . '-'));
85
        $this->view->assign('pageOptions', $pageOptions);
86
87
    }
88
}
89