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
03:35
created

NavigationController   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 81
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 41
dl 0
loc 81
rs 10
c 0
b 0
f 0
wmc 11

2 Methods

Rating   Name   Duplication   Size   Complexity  
B mainAction() 0 54 10
A pageSelectAction() 0 13 1
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
        $uriBuilder = $this->getControllerContext()->getUriBuilder();
35
        $uri = $uriBuilder->reset()
36
            ->setArguments(
37
                [
38
                    'tx_dlf' => [
39
                        'id' => $pageSelectForm->getId(),
0 ignored issues
show
Bug introduced by
The method getId() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

39
                        'id' => $pageSelectForm->/** @scrutinizer ignore-call */ getId(),

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
40
                        'page' => $pageSelectForm->getPage()
41
                    ]
42
                ]
43
            )
44
            ->uriFor('main');
45
        $this->redirectToUri($uri);
46
    }
47
48
    /**
49
     * The main method of the plugin
50
     *
51
     * @return void
52
     */
53
    public function mainAction()
54
    {
55
        // Load current document.
56
        $this->loadDocument($this->requestData);
57
        if (
58
            $this->document === null
59
            || $this->document->getDoc() === null
60
        ) {
61
            // Quit without doing anything if required variables are not set.
62
            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...
63
        } else {
64
            // Set default values if not set.
65
            if ($this->document->getDoc()->numPages > 0) {
66
                if (!empty($this->requestData['logicalPage'])) {
67
                    $this->requestData['page'] = $this->document->getDoc()->getPhysicalPage($this->requestData['logicalPage']);
68
                    // The logical page parameter should not appear
69
                    unset($this->requestData['logicalPage']);
70
                }
71
                // Set default values if not set.
72
                // $this->requestData['page'] may be integer or string (physical structure @ID)
73
                if (
74
                    (int) $this->requestData['page'] > 0
75
                    || empty($this->requestData['page'])
76
                ) {
77
                    $this->requestData['page'] = MathUtility::forceIntegerInRange((int) $this->requestData['page'], 1, $this->document->getDoc()->numPages, 1);
78
                } else {
79
                    $this->requestData['page'] = array_search($this->requestData['page'], $this->document->getDoc()->physicalStructure);
80
                }
81
                $this->requestData['double'] = MathUtility::forceIntegerInRange($this->requestData['double'], 0, 1, 0);
82
            } else {
83
                $this->requestData['page'] = 0;
84
                $this->requestData['double'] = 0;
85
            }
86
        }
87
88
        // Steps for X pages backward / forward. Double page view uses double steps.
89
        $pageSteps = $this->settings['pageStep'] * ($this->requestData['double'] + 1);
90
91
        $this->view->assign('pageSteps', $pageSteps);
92
        $this->view->assign('numPages', $this->document->getDoc()->numPages);
93
        $this->view->assign('viewData', $this->viewData);
94
95
        $pageOptions = [];
96
        for ($i = 1; $i <= $this->document->getDoc()->numPages; $i++) {
97
            $pageOptions[$i] = '[' . $i . ']' . ($this->document->getDoc()->physicalStructureInfo[$this->document->getDoc()->physicalStructure[$i]]['orderlabel'] ? ' - ' . htmlspecialchars($this->document->getDoc()->physicalStructureInfo[$this->document->getDoc()->physicalStructure[$i]]['orderlabel']) : '');
98
        }
99
        $this->view->assign('pageOptions', $pageOptions);
100
101
        // prepare feature array for fluid
102
        $features = [];
103
        foreach (explode(',', $this->settings['features']) as $feature) {
104
            $features[$feature] = true;
105
        }
106
        $this->view->assign('features', $features);
107
    }
108
}
109