We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 19 | 
| Paths | 20 | 
| Total Lines | 59 | 
| Code Lines | 43 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 4 | ||
| Bugs | 0 | Features | 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  | 
            ||
| 74 |     private function getAuthors() { | 
            ||
| 75 |         $authors = $this->xml->xpath('./mods:name[./mods:role/mods:roleTerm[@type="code" and @authority="marcrelator"]="aut"]'); | 
            ||
| 76 | |||
| 77 | // Get "author" and "author_sorting" again if that was too sophisticated.  | 
            ||
| 78 |         if (empty($authors)) { | 
            ||
| 79 | // Get all names which do not have any role term assigned and assume these are authors.  | 
            ||
| 80 |             $authors = $this->xml->xpath('./mods:name[not(./mods:role)]'); | 
            ||
| 81 | }  | 
            ||
| 82 |         if (!empty($authors)) { | 
            ||
| 83 |             for ($i = 0, $j = count($authors); $i < $j; $i++) { | 
            ||
| 84 |                 $authors[$i]->registerXPathNamespace('mods', 'http://www.loc.gov/mods/v3'); | 
            ||
| 85 | |||
| 86 |                 $identifier = $authors[$i]->xpath('./mods:nameIdentifier'); | 
            ||
| 87 |                 if ($identifier[0]['type'] == 'orcid' && !empty((string) $identifier[0])) { | 
            ||
| 88 |                     $orcidIdParts = explode('/', (string) $identifier[0]); | 
            ||
| 89 | $orcidId = trim(end($orcidIdParts));  | 
            ||
| 90 |                     if (!str_contains($orcidId, 'orcid=')) { | 
            ||
| 91 | $profile = new OrcidProfile($orcidId);  | 
            ||
| 92 | $this->metadata['author'][$i] = $profile->getFullName();  | 
            ||
| 93 | }  | 
            ||
| 94 |                 } else { | 
            ||
| 95 | // Check if there is a display form.  | 
            ||
| 96 |                     if (($displayForm = $authors[$i]->xpath('./mods:displayForm'))) { | 
            ||
| 97 | $this->metadata['author'][$i] = (string) $displayForm[0];  | 
            ||
| 98 |                     } elseif (($nameParts = $authors[$i]->xpath('./mods:namePart'))) { | 
            ||
| 99 | $name = [];  | 
            ||
| 100 | $k = 4;  | 
            ||
| 101 |                         foreach ($nameParts as $namePart) { | 
            ||
| 102 | if (  | 
            ||
| 103 | isset($namePart['type'])  | 
            ||
| 104 | && (string) $namePart['type'] == 'family'  | 
            ||
| 105 |                             ) { | 
            ||
| 106 | $name[0] = (string) $namePart;  | 
            ||
| 107 | } elseif (  | 
            ||
| 108 | isset($namePart['type'])  | 
            ||
| 109 | && (string) $namePart['type'] == 'given'  | 
            ||
| 110 |                             ) { | 
            ||
| 111 | $name[1] = (string) $namePart;  | 
            ||
| 112 | } elseif (  | 
            ||
| 113 | isset($namePart['type'])  | 
            ||
| 114 | && (string) $namePart['type'] == 'termsOfAddress'  | 
            ||
| 115 |                             ) { | 
            ||
| 116 | $name[2] = (string) $namePart;  | 
            ||
| 117 | } elseif (  | 
            ||
| 118 | isset($namePart['type'])  | 
            ||
| 119 | && (string) $namePart['type'] == 'date'  | 
            ||
| 120 |                             ) { | 
            ||
| 121 | $name[3] = (string) $namePart;  | 
            ||
| 122 |                             } else { | 
            ||
| 123 | $name[$k] = (string) $namePart;  | 
            ||
| 124 | }  | 
            ||
| 125 | $k++;  | 
            ||
| 126 | }  | 
            ||
| 127 | ksort($name);  | 
            ||
| 128 |                         $this->metadata['author'][$i] = trim(implode(', ', $name)); | 
            ||
| 129 | }  | 
            ||
| 130 | // Append "valueURI" to name using Unicode unit separator.  | 
            ||
| 131 |                     if (isset($authors[$i]['valueURI'])) { | 
            ||
| 132 | $this->metadata['author'][$i] .= chr(31) . (string) $authors[$i]['valueURI'];  | 
            ||
| 133 | }  | 
            ||
| 261 |