We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 16 |
| Paths | 8 |
| Total Lines | 121 |
| Code Lines | 80 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 1 |
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:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 37 | public function mainAction() |
||
| 38 | { |
||
| 39 | // access to GET parameter tx_dlf_feeds['collection'] |
||
| 40 | $requestData = $this->request->getArguments(); |
||
| 41 | |||
| 42 | // get library information |
||
| 43 | $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
||
| 44 | ->getQueryBuilderForTable('tx_dlf_libraries'); |
||
| 45 | |||
| 46 | $result = $queryBuilder |
||
| 47 | ->select('tx_dlf_libraries.label AS label') |
||
| 48 | ->from('tx_dlf_libraries') |
||
| 49 | ->where( |
||
| 50 | $queryBuilder->expr()->eq('tx_dlf_libraries.pid', (int) $this->settings['pages']), |
||
| 51 | $queryBuilder->expr()->eq('tx_dlf_libraries.uid', (int) $this->settings['library']) |
||
| 52 | ) |
||
| 53 | ->setMaxResults(1) |
||
| 54 | ->execute(); |
||
| 55 | |||
| 56 | $feedMeta = []; |
||
| 57 | $documents = []; |
||
| 58 | |||
| 59 | if ($resArray = $result->fetch()) { |
||
| 60 | $feedMeta['copyright'] = $resArray['label']; |
||
| 61 | } else { |
||
| 62 | $this->logger->error('Failed to fetch label of selected library with "' . $this->settings['library'] . '"'); |
||
|
1 ignored issue
–
show
|
|||
| 63 | } |
||
| 64 | |||
| 65 | if ( |
||
| 66 | !$this->settings['excludeOtherCollections'] |
||
| 67 | || empty($requestData['collection']) |
||
| 68 | || GeneralUtility::inList($this->settings['collections'], $requestData['collection']) |
||
| 69 | ) { |
||
| 70 | $additionalWhere = ''; |
||
| 71 | // Check for pre-selected collections. |
||
| 72 | if (!empty($requestData['collection'])) { |
||
| 73 | $additionalWhere = 'tx_dlf_collections.uid=' . intval($requestData['collection']); |
||
| 74 | } elseif (!empty($this->settings['collections'])) { |
||
| 75 | $additionalWhere = 'tx_dlf_collections.uid IN (' . implode(',', GeneralUtility::intExplode(',', $this->settings['collections'])) . ')'; |
||
| 76 | } |
||
| 77 | |||
| 78 | // get documents |
||
| 79 | $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
||
| 80 | ->getQueryBuilderForTable('tx_dlf_documents'); |
||
| 81 | |||
| 82 | $result = $queryBuilder |
||
| 83 | ->select( |
||
| 84 | 'tx_dlf_documents.uid AS uid', |
||
| 85 | 'tx_dlf_documents.partof AS partof', |
||
| 86 | 'tx_dlf_documents.title AS title', |
||
| 87 | 'tx_dlf_documents.volume AS volume', |
||
| 88 | 'tx_dlf_documents.author AS author', |
||
| 89 | 'tx_dlf_documents.record_id AS record_id', |
||
| 90 | 'tx_dlf_documents.tstamp AS tstamp', |
||
| 91 | 'tx_dlf_documents.crdate AS crdate' |
||
| 92 | ) |
||
| 93 | ->from('tx_dlf_documents') |
||
| 94 | ->join( |
||
| 95 | 'tx_dlf_documents', |
||
| 96 | 'tx_dlf_relations', |
||
| 97 | 'tx_dlf_documents_collections_mm', |
||
| 98 | $queryBuilder->expr()->eq('tx_dlf_documents.uid', $queryBuilder->quoteIdentifier('tx_dlf_documents_collections_mm.uid_local')) |
||
| 99 | ) |
||
| 100 | ->join( |
||
| 101 | 'tx_dlf_documents_collections_mm', |
||
| 102 | 'tx_dlf_collections', |
||
| 103 | 'tx_dlf_collections', |
||
| 104 | $queryBuilder->expr()->eq('tx_dlf_collections.uid', $queryBuilder->quoteIdentifier('tx_dlf_documents_collections_mm.uid_foreign')) |
||
| 105 | ) |
||
| 106 | ->where( |
||
| 107 | $queryBuilder->expr()->eq('tx_dlf_documents.pid', $queryBuilder->createNamedParameter((int) $this->settings['pages'])), |
||
| 108 | $queryBuilder->expr()->eq('tx_dlf_documents_collections_mm.ident', $queryBuilder->createNamedParameter('docs_colls')), |
||
| 109 | $queryBuilder->expr()->eq('tx_dlf_collections.pid', $queryBuilder->createNamedParameter((int) $this->settings['pages'])), |
||
| 110 | $additionalWhere |
||
| 111 | ) |
||
| 112 | ->groupBy('tx_dlf_documents.uid') |
||
| 113 | ->orderBy('tx_dlf_documents.tstamp', 'DESC') |
||
| 114 | ->setMaxResults((int) $this->settings['limit']) |
||
| 115 | ->execute(); |
||
| 116 | |||
| 117 | $rows = $result->fetchAll(); |
||
| 118 | |||
| 119 | foreach ($rows as $resArray) { |
||
| 120 | |||
| 121 | $title = ''; |
||
| 122 | // Get title of superior document. |
||
| 123 | if ((empty($resArray['title']) || !empty($this->settings['prependSuperiorTitle'])) |
||
| 124 | && !empty($resArray['partof']) |
||
| 125 | ) { |
||
| 126 | $superiorTitle = Document::getTitle($resArray['partof'], true); |
||
| 127 | if (!empty($superiorTitle)) { |
||
| 128 | $title .= '[' . $superiorTitle . ']'; |
||
| 129 | } |
||
| 130 | } |
||
| 131 | // Get title of document. |
||
| 132 | if (!empty($resArray['title'])) { |
||
| 133 | $title .= ' ' . $resArray['title']; |
||
| 134 | } |
||
| 135 | // Set default title if empty. |
||
| 136 | if (empty($title)) { |
||
| 137 | $title = LocalizationUtility::translate('noTitle', 'dlf'); |
||
| 138 | } |
||
| 139 | // Append volume information. |
||
| 140 | if (!empty($resArray['volume'])) { |
||
| 141 | $title .= ', ' . LocalizationUtility::translate('volume', 'dlf') . ' ' . $resArray['volume']; |
||
| 142 | } |
||
| 143 | // Is this document new or updated? |
||
| 144 | if ($resArray['crdate'] == $resArray['tstamp']) { |
||
| 145 | $title = LocalizationUtility::translate('plugins.feeds.new', 'dlf') . ' ' . trim($title); |
||
| 146 | } else { |
||
| 147 | $title = LocalizationUtility::translate('plugins.feeds.update', 'dlf') . ' ' . trim($title); |
||
| 148 | } |
||
| 149 | |||
| 150 | $resArray['title'] = $title; |
||
| 151 | $documents[] = $resArray; |
||
| 152 | } |
||
| 153 | |||
| 154 | } |
||
| 155 | |||
| 156 | $this->view->assign('documents', $documents); |
||
| 157 | $this->view->assign('feedMeta', $feedMeta); |
||
| 158 | |||
| 161 |
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.