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 (#870)
by
unknown
09:22
created

NavigationController::mainAction()   B

Complexity

Conditions 10
Paths 31

Size

Total Lines 54
Code Lines 32

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 10
eloc 32
nc 31
nop 0
dl 0
loc 54
rs 7.6666
c 0
b 0
f 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
/**
19
 * Controller class for the plugin 'Navigation'.
20
 *
21
 * @author Sebastian Meyer <[email protected]>
22
 * @package TYPO3
23
 * @subpackage dlf
24
 * @access public
25
 */
26
class NavigationController extends AbstractController
27
{
28
    /**
29
     * Method to get the page select values and use them with chash
30
     * @param \Kitodo\Dlf\Domain\Model\PageSelectForm|NULL $pageSelectForm
31
     * @return void
32
     */
33
    public function pageSelectAction(\Kitodo\Dlf\Domain\Model\PageSelectForm $pageSelectForm = NULL) {
34
        if ($pageSelectForm) {
35
            $uriBuilder = $this->getControllerContext()->getUriBuilder();
36
            $uri = $uriBuilder->reset()
37
                ->setArguments(
38
                    [
39
                        'tx_dlf' => [
40
                            'id' => $pageSelectForm->getId(),
41
                            'page' => $pageSelectForm->getPage()
42
                        ]
43
                    ]
44
                )
45
                ->uriFor('main');
46
            $this->redirectToUri($uri);
47
        }
48
    }
49
50
    /**
51
     * The main method of the plugin
52
     *
53
     * @return void
54
     */
55
    public function mainAction()
56
    {
57
        // Load current document.
58
        $this->loadDocument($this->requestData);
59
        if (
60
            $this->document === null
61
            || $this->document->getDoc() === null
62
        ) {
63
            // Quit without doing anything if required variables are not set.
64
            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...
65
        } else {
66
            // Set default values if not set.
67
            if ($this->document->getDoc()->numPages > 0) {
68
                if (!empty($this->requestData['logicalPage'])) {
69
                    $this->requestData['page'] = $this->document->getDoc()->getPhysicalPage($this->requestData['logicalPage']);
70
                    // The logical page parameter should not appear
71
                    unset($this->requestData['logicalPage']);
72
                }
73
                // Set default values if not set.
74
                // $this->requestData['page'] may be integer or string (physical structure @ID)
75
                if (
76
                    (int) $this->requestData['page'] > 0
77
                    || empty($this->requestData['page'])
78
                ) {
79
                    $this->requestData['page'] = MathUtility::forceIntegerInRange((int) $this->requestData['page'], 1, $this->document->getDoc()->numPages, 1);
80
                } else {
81
                    $this->requestData['page'] = array_search($this->requestData['page'], $this->document->getDoc()->physicalStructure);
82
                }
83
                $this->requestData['double'] = MathUtility::forceIntegerInRange($this->requestData['double'], 0, 1, 0);
84
            } else {
85
                $this->requestData['page'] = 0;
86
                $this->requestData['double'] = 0;
87
            }
88
        }
89
90
        // Steps for X pages backward / forward. Double page view uses double steps.
91
        $pageSteps = $this->settings['pageStep'] * ($this->requestData['double'] + 1);
92
93
        $this->view->assign('pageSteps', $pageSteps);
94
        $this->view->assign('numPages', $this->document->getDoc()->numPages);
95
        $this->view->assign('viewData', $this->viewData);
96
97
        $pageOptions = [];
98
        for ($i = 1; $i <= $this->document->getDoc()->numPages; $i++) {
99
            $pageOptions[$i] = '[' . $i . ']' . ($this->document->getDoc()->physicalStructureInfo[$this->document->getDoc()->physicalStructure[$i]]['orderlabel'] ? ' - ' . htmlspecialchars($this->document->getDoc()->physicalStructureInfo[$this->document->getDoc()->physicalStructure[$i]]['orderlabel']) : '');
100
        }
101
        $this->view->assign('pageOptions', $pageOptions);
102
103
        // prepare feature array for fluid
104
        $features = [];
105
        foreach (explode(',', $this->settings['features']) as $feature) {
106
            $features[$feature] = true;
107
        }
108
        $this->view->assign('features', $features);
109
    }
110
}
111