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 — dev-extbase-fluid (#754)
by Alexander
03:00
created

ListViewController::getSubEntries()   D

Complexity

Conditions 21
Paths 99

Size

Total Lines 69
Code Lines 44

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 21
eloc 44
c 1
b 0
f 0
nc 99
nop 1
dl 0
loc 69
rs 4.1666

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\Domain\Model\Metadata;
15
use TYPO3\CMS\Core\Utility\GeneralUtility;
16
use Kitodo\Dlf\Domain\Repository\MetadataRepository;
17
18
/**
19
 * Plugin 'List View' for the 'dlf' extension
20
 *
21
 * @author Sebastian Meyer <[email protected]>
22
 * @author Henrik Lochmann <[email protected]>
23
 * @author Frank Ulrich Weber <[email protected]>
24
 * @package TYPO3
25
 * @subpackage dlf
26
 * @access public
27
 */
28
class ListViewController extends AbstractController
29
{
30
31
    /**
32
     * @var MetadataRepository
33
     */
34
    protected $metadataRepository;
35
36
    /**
37
     * @param MetadataRepository $metadataRepository
38
     */
39
    public function injectMetadataRepository(MetadataRepository $metadataRepository)
40
    {
41
        $this->metadataRepository = $metadataRepository;
42
    }
43
44
    /**
45
     * The main method of the plugin
46
     *
47
     * @return void
48
     */
49
    public function mainAction()
50
    {
51
        $searchRequestData = GeneralUtility::_GPmerged('tx_dlf_search');
52
        $listRequestData = GeneralUtility::_GPmerged('tx_dlf_listview');
53
        $collectionRequestData = GeneralUtility::_GPmerged('tx_dlf_collection');
54
55
        $searchRequestData = array_merge($searchRequestData, $listRequestData);
56
        $searchRequestData = array_merge($searchRequestData, $collectionRequestData);
57
58
        // ABTODO: This plugin may be called from search and collection plugin...
59
60
        $searchParams = $searchRequestData['searchParameter'];
61
        $widgetPage = $searchRequestData['widgetPage'];
62
        if (empty($widgetPage)) {
63
            $widgetPage = ['currentPage' => 1];
64
        }
65
66
        // get all sortable metadata records
67
        $sortableMetadata = $this->metadataRepository->findByIsSortable(true);
0 ignored issues
show
Bug introduced by
The method findByIsSortable() does not exist on Kitodo\Dlf\Domain\Repository\MetadataRepository. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

67
        /** @scrutinizer ignore-call */ 
68
        $sortableMetadata = $this->metadataRepository->findByIsSortable(true);
Loading history...
68
69
        // get all metadata records to be shown in results
70
        $listedMetadata = $this->metadataRepository->findByIsListed(true);
0 ignored issues
show
Bug introduced by
The method findByIsListed() does not exist on Kitodo\Dlf\Domain\Repository\MetadataRepository. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

70
        /** @scrutinizer ignore-call */ 
71
        $listedMetadata = $this->metadataRepository->findByIsListed(true);
Loading history...
71
72
        if (is_array($searchParams) && !empty($searchParams)) {
73
            $solrResults = $this->documentRepository->findSolrByCollection('', $this->settings, $searchParams, $listedMetadata);
0 ignored issues
show
Bug introduced by
'' of type string is incompatible with the type Kitodo\Dlf\Domain\Model\Collection expected by parameter $collection of Kitodo\Dlf\Domain\Reposi...:findSolrByCollection(). ( Ignorable by Annotation )

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

73
            $solrResults = $this->documentRepository->findSolrByCollection(/** @scrutinizer ignore-type */ '', $this->settings, $searchParams, $listedMetadata);
Loading history...
74
        }
75
76
        $documents = $solrResults['documents'] ? : [];
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $solrResults does not seem to be defined for all execution paths leading up to this point.
Loading history...
77
        $this->view->assign('documents', $documents);
78
        $rawResults = $solrResults['solrResults']['documents'] ? : [];
79
        $this->view->assign('numResults', count($rawResults));
80
        $this->view->assign('widgetPage', $widgetPage);
81
        $this->view->assign('lastSearch', $searchParams);
82
83
        $this->view->assign('sortableMetadata', $sortableMetadata);
84
        $this->view->assign('listedMetadata', $listedMetadata);
85
    }
86
}
87