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.
Completed
Push — master ( b811c3...b34a1c )
by Sebastian
19s
created

tx_dlf_toolsFulltext::main()   C

Complexity

Conditions 9
Paths 17

Size

Total Lines 66
Code Lines 27

Duplication

Lines 39
Ratio 59.09 %

Importance

Changes 0
Metric Value
cc 9
eloc 27
nc 17
nop 2
dl 39
loc 66
rs 6.4099
c 0
b 0
f 0

How to fix   Long Method   

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
/**
13
 * Tool 'Fulltext selection' for the plugin 'DLF: Toolbox' of the 'dlf' extension.
14
 *
15
 * @author	Sebastian Meyer <[email protected]>
16
 * @author	Alexander Bigga <[email protected]>
17
 * @package	TYPO3
18
 * @subpackage	tx_dlf
19
 * @access	public
20
 */
21
class tx_dlf_toolsFulltext extends tx_dlf_plugin {
22
23
	public $scriptRelPath = 'plugins/toolbox/tools/fulltext/class.tx_dlf_toolsFulltext.php';
24
25
	/**
26
	 * The main method of the PlugIn
27
	 *
28
	 * @access	public
29
	 *
30
	 * @param	string		$content: The PlugIn content
31
	 * @param	array		$conf: The PlugIn configuration
32
	 *
33
	 * @return	string		The content that is displayed on the website
34
	 */
35
	public function main($content, $conf) {
36
37
		$this->init($conf);
38
39
		// Merge configuration with conf array of toolbox.
40
		$this->conf = tx_dlf_helper::array_merge_recursive_overrule($this->cObj->data['conf'], $this->conf);
0 ignored issues
show
Bug Best Practice introduced by
The property conf does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
41
42
		// Load current document.
43
		$this->loadDocument();
44
45 View Code Duplication
		if ($this->doc === NULL || $this->doc->numPages < 1 || empty($this->conf['fileGrpFulltext'])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
46
47
			// Quit without doing anything if required variables are not set.
48
			return $content;
49
50
		} else {
51
52
			if (!empty($this->piVars['logicalPage'])) {
53
54
				$this->piVars['page'] = $this->doc->getPhysicalPage($this->piVars['logicalPage']);
0 ignored issues
show
Bug Best Practice introduced by
The property piVars does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
55
				// The logical page parameter should not appear again
56
				unset($this->piVars['logicalPage']);
57
58
			}
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
64
				$this->piVars['page'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange((int) $this->piVars['page'], 1, $this->doc->numPages, 1);
0 ignored issues
show
Bug introduced by
The type TYPO3\CMS\Core\Utility\MathUtility was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
65
66
			} else {
67
68
				$this->piVars['page'] = array_search($this->piVars['page'], $this->doc->physicalStructure);
69
70
			}
71
72
			$this->piVars['double'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->piVars['double'], 0, 1, 0);
73
74
		}
75
76
		// Load template file.
77 View Code Duplication
		if (!empty($this->conf['toolTemplateFile'])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
78
79
			$this->template = $this->cObj->getSubpart($this->cObj->fileResource($this->conf['toolTemplateFile']), '###TEMPLATE###');
80
81
		} else {
82
83
			$this->template = $this->cObj->getSubpart($this->cObj->fileResource('EXT:dlf/plugins/toolbox/tools/fulltext/template.tmpl'), '###TEMPLATE###');
84
85
		}
86
87
88
		$fullTextFile = $this->doc->physicalStructureInfo[$this->doc->physicalStructure[$this->piVars['page']]]['files'][$this->conf['fileGrpFulltext']];
89
90
		if (!empty($fullTextFile)) {
91
			$markerArray['###FULLTEXT_SELECT###'] = '<a class="select switchoff" id="tx-dlf-tools-fulltext" title="" data-dic="fulltext-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...
92
					.$this->pi_getLL('fulltext-on', '', TRUE).';fulltext-off:'
93
					.$this->pi_getLL('fulltext-off', '', TRUE).'">&nbsp;</a>';
94
		} else {
95
			$markerArray['###FULLTEXT_SELECT###'] = '<span class="no-fulltext">' . $this->pi_getLL('fulltext-not-available', '', TRUE) . '</span>';
96
		}
97
98
		$content .= $this->cObj->substituteMarkerArray($this->template, $markerArray);
99
100
		return $this->pi_wrapInBaseClass($content);
101
102
	}
103
104
}
105