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 (#336)
by
unknown
03:50
created

AnnotationTool   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 8
eloc 26
dl 0
loc 54
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B main() 0 37 8
1
<?php
2
namespace Kitodo\Dlf\Plugin\Tools;
3
4
/**
5
 * (c) Kitodo. Key to digital objects e.V. <[email protected]>
6
 *
7
 * This file is part of the Kitodo and TYPO3 projects.
8
 *
9
 * @license GNU General Public License version 3 or later.
10
 * For the full copyright and license information, please read the
11
 * LICENSE.txt file that was distributed with this source code.
12
 */
13
14
use Kitodo\Dlf\Common\AbstractPlugin;
15
use Kitodo\Dlf\Common\Helper;
16
17
/**
18
 * Tool 'Annotation selection' for the plugin 'DLF: Toolbox' of the 'dlf' extension.
19
 * Allows the display of IIIF annotations.
20
 *
21
 * @author Sebastian Meyer <[email protected]>
22
 * @author Alexander Bigga <[email protected]>
23
 * @author Lutz Helm <[email protected]>
24
 * @package TYPO3
25
 * @subpackage dlf
26
 * @access public
27
 */
28
class AnnotationTool extends AbstractPlugin {
29
    /**
30
     * @access public
31
     * @var string
32
     */
33
    public $scriptRelPath = 'Classes/Plugin/Tools/AnnotationTool.php';
34
35
    /**
36
     * The main method of the PlugIn
37
     *
38
     * @access public
39
     *
40
     * @param string  $content: The PlugIn content
41
     * @param array  $conf: The PlugIn configuration
42
     *
43
     * @return string  The content that is displayed on the website
44
     */
45
    public function main($content, $conf) {
46
        $this->init($conf);
47
        // Merge configuration with conf array of toolbox.
48
        $this->conf = Helper::mergeRecursiveWithOverrule($this->cObj->data['conf'], $this->conf);
49
        // Load current document.
50
        $this->loadDocument();
51
        if ($this->doc === NULL || $this->doc->numPages < 1) {
0 ignored issues
show
Bug Best Practice introduced by
The property $numPages is declared protected in Kitodo\Dlf\Common\Document. Since you implement __get, consider adding a @property or @property-read.
Loading history...
52
            // Quit without doing anything if required variables are not set.
53
            return $content;
54
        } else {
55
            if (!empty($this->piVars['logicalPage'])) {
56
                $this->piVars['page'] = $this->doc->getPhysicalPage($this->piVars['logicalPage']);
57
                // The logical page parameter should not appear again
58
                unset($this->piVars['logicalPage']);
59
            }
60
            // Set default values if not set.
61
            // $this->piVars['page'] may be integer or string (physical structure @ID)
62
            if ((int) $this->piVars['page'] > 0 || empty($this->piVars['page'])) {
63
                $this->piVars['page'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange((int) $this->piVars['page'], 1, $this->doc->numPages, 1);
64
            } else {
65
                $this->piVars['page'] = array_search($this->piVars['page'], $this->doc->physicalStructure);
0 ignored issues
show
Bug Best Practice introduced by
The property $physicalStructure is declared protected in Kitodo\Dlf\Common\Document. Since you implement __get, consider adding a @property or @property-read.
Loading history...
66
            }
67
            $this->piVars['double'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->piVars['double'], 0, 1, 0);
68
        }
69
        // Load template file.
70
        $this->getTemplate();
71
        $annotationContainers = $this->doc->physicalStructureInfo[$this->doc->physicalStructure[$this->piVars['page']]]['annotationContainers'];
0 ignored issues
show
Bug Best Practice introduced by
The property $physicalStructureInfo is declared protected in Kitodo\Dlf\Common\Document. Since you implement __get, consider adding a @property or @property-read.
Loading history...
72
        if ($annotationContainers != null && sizeof($annotationContainers)>0) {
73
            $markerArray['###ANNOTATION_SELECT###'] = '<a class="select switchoff" id="tx-dlf-tools-annotations" title="" data-dic="annotations-on:'
1 ignored issue
show
Comprehensibility Best Practice introduced by
$markerArray was never initialized. Although not strictly required by PHP, it is generally a good practice to add $markerArray = array(); before regardless.
Loading history...
74
                .$this->pi_getLL('annotations-on', '', TRUE).';annotations-off:'
75
                    .$this->pi_getLL('annotations-off', '', TRUE).'">&nbsp;</a>';
76
                    // TODO selector for different motivations
77
        } else {
78
            $markerArray['###ANNOTATION_SELECT###'] = '<span class="no-annotations">'.$this->pi_getLL('annotations-not-available', '', TRUE).'</span>';
79
        }
80
        $content .= $this->cObj->substituteMarkerArray($this->template, $markerArray);
0 ignored issues
show
Deprecated Code introduced by
The function TYPO3\CMS\Frontend\Conte...substituteMarkerArray() has been deprecated: since TYPO3 v8, will be removed in TYPO3 v9, please use the MarkerBasedTemplateService instead. ( Ignorable by Annotation )

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

80
        $content .= /** @scrutinizer ignore-deprecated */ $this->cObj->substituteMarkerArray($this->template, $markerArray);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
81
        return $this->pi_wrapInBaseClass($content);
82
    }
83
}
84