We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 11 |
| Paths | 7 |
| Total Lines | 112 |
| Code Lines | 84 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
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 |
||
| 103 | $GLOBALS['LANG']->getLL('cliDispatcher.cliNotOkayMsg'), |
||
| 104 | $GLOBALS['LANG']->getLL('cliDispatcher.cliNotOkay'), |
||
| 105 | \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR |
||
| 106 | ); |
||
| 107 | } |
||
| 108 | return Helper::renderFlashMessages(); |
||
| 109 | } |
||
| 110 | |||
| 111 | /** |
||
| 112 | * Make sure the essential namespaces are defined. |
||
| 113 | * |
||
| 114 | * @access public |
||
| 115 | * |
||
| 116 | * @param array &$params: An array with parameters |
||
| 117 | * @param \TYPO3\CMS\Core\TypoScript\ConfigurationForm &$pObj: The parent object |
||
| 118 | * |
||
| 119 | * @return string Message informing the user of success or failure |
||
| 120 | */ |
||
| 121 | public function checkMetadataFormats(&$params, &$pObj) { |
||
|
2 ignored issues
–
show
|
|||
| 122 | $nsDefined = [ |
||
| 123 | 'MODS' => FALSE, |
||
| 124 | 'TEIHDR' => FALSE, |
||
| 125 | 'ALTO' => FALSE |
||
| 126 | ]; |
||
| 127 | // Check existing format specifications. |
||
| 128 | $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
||
| 129 | 'type', |
||
| 130 | 'tx_dlf_formats', |
||
| 131 | '1=1' |
||
| 132 | .Helper::whereClause('tx_dlf_formats') |
||
| 133 | ); |
||
| 134 | while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { |
||
| 135 | $nsDefined[$resArray['type']] = TRUE; |
||
| 136 | } |
||
| 137 | // Build data array. |
||
| 138 | $data = []; |
||
| 139 | // Add MODS namespace. |
||
| 140 | if (!$nsDefined['MODS']) { |
||
| 141 | $data['tx_dlf_formats'][uniqid('NEW')] = [ |
||
| 142 | 'pid' => 0, |
||
| 143 | 'type' => 'MODS', |
||
| 144 | 'root' => 'mods', |
||
| 145 | 'namespace' => 'http://www.loc.gov/mods/v3', |
||
| 146 | 'class' => 'Kitodo\\\\Dlf\\\\Format\\\\Mods' |
||
| 147 | ]; |
||
| 148 | } |
||
| 149 | // Add TEIHDR namespace. |
||
| 150 | if (!$nsDefined['TEIHDR']) { |
||
| 151 | $data['tx_dlf_formats'][uniqid('NEW')] = [ |
||
| 152 | 'pid' => 0, |
||
| 153 | 'type' => 'TEIHDR', |
||
| 154 | 'root' => 'teiHeader', |
||
| 155 | 'namespace' => 'http://www.tei-c.org/ns/1.0', |
||
| 156 | 'class' => 'Kitodo\\\\Dlf\\\\Format\\\\TeiHeader' |
||
| 157 | ]; |
||
| 158 | } |
||
| 159 | // Add ALTO namespace. |
||
| 160 | if (!$nsDefined['ALTO']) { |
||
| 161 | $data['tx_dlf_formats'][uniqid('NEW')] = [ |
||
| 162 | 'pid' => 0, |
||
| 163 | 'type' => 'ALTO', |
||
| 164 | 'root' => 'alto', |
||
| 165 | 'namespace' => 'http://www.loc.gov/standards/alto/ns-v2#', |
||
| 166 | 'class' => 'Kitodo\\\\Dlf\\\\Format\\\\Alto' |
||
| 167 | ]; |
||
| 168 | } |
||
| 169 | if (!empty($data)) { |
||
| 170 | // Process changes. |
||
| 171 | $substUid = Helper::processDBasAdmin($data); |
||
| 172 | if (!empty($substUid)) { |
||
| 173 | Helper::addMessage( |
||
| 174 | $GLOBALS['LANG']->getLL('metadataFormats.nsCreatedMsg'), |
||
| 175 | $GLOBALS['LANG']->getLL('metadataFormats.nsCreated'), |
||
| 176 | \TYPO3\CMS\Core\Messaging\FlashMessage::INFO |
||
| 177 | ); |
||
| 178 | } else { |
||
| 179 | Helper::addMessage( |
||
| 180 | $GLOBALS['LANG']->getLL('metadataFormats.nsNotCreatedMsg'), |
||
| 181 | $GLOBALS['LANG']->getLL('metadataFormats.nsNotCreated'), |
||
| 182 | \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR |
||
| 183 | ); |
||
| 184 | } |
||
| 185 | } else { |
||
| 186 | Helper::addMessage( |
||
| 187 | $GLOBALS['LANG']->getLL('metadataFormats.nsOkayMsg'), |
||
| 188 | $GLOBALS['LANG']->getLL('metadataFormats.nsOkay'), |
||
| 189 | \TYPO3\CMS\Core\Messaging\FlashMessage::OK |
||
| 190 | ); |
||
| 191 | } |
||
| 192 | return Helper::renderFlashMessages(); |
||
| 193 | } |
||
| 194 | |||
| 195 | /** |
||
| 196 | * This is the constructor. |
||
| 197 | * |
||
| 198 | * @access public |
||
| 199 | * |
||
| 200 | * @return void |
||
| 201 | */ |
||
| 202 | public function __construct() { |
||
| 203 | // Load localization file. |
||
| 204 | $GLOBALS['LANG']->includeLLFile('EXT:dlf/Resources/Private/Language/FlashMessages.xml'); |
||
| 205 | // Get current configuration. |
||
| 206 | $this->conf = array_merge((array) unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['dlf']), (array) \TYPO3\CMS\Core\Utility\GeneralUtility::_POST('data')); |
||
| 207 | } |
||
| 208 | } |
||
| 209 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.