We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 10 |
| Paths | 26 |
| Total Lines | 27 |
| Code Lines | 19 |
| 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 |
||
| 37 | public function postProcessRecordId(\SimpleXMLElement &$xml, &$recordId): void |
||
| 38 | { |
||
| 39 | if (!$recordId) { |
||
| 40 | $xml->registerXPathNamespace('mods', 'http://www.loc.gov/mods/v3'); |
||
| 41 | // Get all logical structure nodes with metadata, but without associated METS-Pointers. |
||
| 42 | if (($divs = $xml->xpath('//mets:structMap[@TYPE="LOGICAL"]//mets:div[@DMDID and not(./mets:mptr)]'))) { |
||
| 43 | $smLinks = $xml->xpath('//mets:structLink/mets:smLink'); |
||
| 44 | if (!empty($smLinks)) { |
||
| 45 | foreach ($smLinks as $smLink) { |
||
| 46 | $links[(string) $smLink->attributes('http://www.w3.org/1999/xlink')->from][] = (string) $smLink->attributes('http://www.w3.org/1999/xlink')->to; |
||
| 47 | } |
||
| 48 | foreach ($divs as $div) { |
||
| 49 | if (!empty($links[(string) $div['ID']])) { |
||
| 50 | $id = (string) $div['DMDID']; |
||
| 51 | break; |
||
| 52 | } |
||
| 53 | } |
||
| 54 | } |
||
| 55 | if (empty($id)) { |
||
| 56 | $id = (string) $divs[0]['DMDID']; |
||
| 57 | } |
||
| 58 | $dmdIds = explode(' ', $id); |
||
| 59 | foreach ($dmdIds as $dmdId) { |
||
| 60 | $recordIds = $xml->xpath('//mets:dmdSec[@ID="' . $dmdId . '"]//mods:mods/mods:recordInfo/mods:recordIdentifier'); |
||
| 61 | if (!empty($recordIds)) { |
||
| 62 | $recordId = (string) $recordIds[0]; |
||
| 63 | break; |
||
| 64 | } |
||
| 70 |