| Total Complexity | 46 |
| Total Lines | 288 |
| Duplicated Lines | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
Complex classes like RisReader often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use RisReader, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 27 | class RisReader |
||
| 28 | { |
||
| 29 | public static $tagMap = [ |
||
| 30 | 'FN' => 'File Name', |
||
| 31 | 'VR' => 'Version Number', |
||
| 32 | 'PT' => 'Publication Type', |
||
| 33 | 'AU' => 'Author', |
||
| 34 | 'AF' => 'Author Full Name', |
||
| 35 | 'BA' => 'Book Author', |
||
| 36 | 'BF' => 'Book Author Full Name', |
||
| 37 | 'CA' => 'Group Author', |
||
| 38 | 'GP' => 'Book Group Author', |
||
| 39 | 'BE' => 'Editor', |
||
| 40 | 'TI' => 'Document Title', |
||
| 41 | 'SO' => 'Publication Name', |
||
| 42 | 'SE' => 'Book Series Title', |
||
| 43 | 'BS' => 'Book Series Subtitle', |
||
| 44 | 'LA' => 'Language', |
||
| 45 | 'DT' => 'Document Type', |
||
| 46 | 'CT' => 'Conference Title', |
||
| 47 | 'CY' => 'Conference Date', |
||
| 48 | 'CL' => 'Conference Location', |
||
| 49 | 'SP' => 'Conference Sponsors', |
||
| 50 | 'HO' => 'Conference Host', |
||
| 51 | 'DE' => 'Author Keywords', |
||
| 52 | 'ID' => 'Keywords Plus', |
||
| 53 | 'AB' => 'Abstract', |
||
| 54 | 'C1' => 'Author Address', |
||
| 55 | 'RP' => 'Reprint Address', |
||
| 56 | 'EM' => 'E-mail Address', |
||
| 57 | 'RI' => 'ResearcherID Number', |
||
| 58 | 'OI' => 'ORCID Identifier', |
||
| 59 | 'FU' => 'Funding Agency and Grant Number', |
||
| 60 | 'FX' => 'Funding Text', |
||
| 61 | 'CR' => 'Cited References', |
||
| 62 | 'NR' => 'Cited Reference Count', |
||
| 63 | 'TC' => 'WoS Times Cited Count', |
||
| 64 | 'Z9' => 'Total Times Cited Count', |
||
| 65 | 'U1' => 'Usage Count las 180 days', |
||
| 66 | 'U2' => 'Usage Count since 2013', |
||
| 67 | 'PU' => 'Publisher', |
||
| 68 | 'PI' => 'Publisher City', |
||
| 69 | 'PA' => 'Publisher Address', |
||
| 70 | 'SN' => 'ISSN', |
||
| 71 | 'EI' => 'eISSN', |
||
| 72 | 'BN' => 'ISBN', |
||
| 73 | 'J9' => 'Character-29 Source Abbreviation', |
||
| 74 | 'JI' => 'ISO Source Abbreviation', |
||
| 75 | 'PD' => 'Publication Date', |
||
| 76 | 'PY' => 'Year Published', |
||
| 77 | 'VL' => 'Volume', |
||
| 78 | 'IS' => 'Issue', |
||
| 79 | 'SI' => 'Special Issue', |
||
| 80 | 'PN' => 'Part Number', |
||
| 81 | 'SU' => 'Supplement', |
||
| 82 | 'MA' => 'Meeting Abstract', |
||
| 83 | 'BP' => 'Beginning Page', |
||
| 84 | 'EP' => 'Ending Page', |
||
| 85 | 'AR' => 'Article Number', |
||
| 86 | 'DI' => 'DOI', |
||
| 87 | 'D2' => 'Book DOI', |
||
| 88 | 'EA' => 'Early access date', |
||
| 89 | 'EY' => 'Early access year', |
||
| 90 | 'PG' => 'Page Count', |
||
| 91 | 'P2' => 'Chapter Count', |
||
| 92 | 'WC' => 'WoS Categories', |
||
| 93 | 'SC' => 'Research Areas', |
||
| 94 | 'GA' => 'Document Delivery Number', |
||
| 95 | 'PM' => 'PubMed ID', |
||
| 96 | 'UT' => 'Accession Number', |
||
| 97 | 'OA' => 'Open Access Indicator', |
||
| 98 | 'HP' => 'ESI Hot Paper', |
||
| 99 | 'HC' => 'ESI Highly Cited Paper', |
||
| 100 | 'DA' => 'Date generated', |
||
| 101 | 'ER' => 'End of Record', |
||
| 102 | 'EF' => 'End of File' |
||
| 103 | ]; |
||
| 104 | |||
| 105 | |||
| 106 | public static $publicationTypes = [ |
||
| 107 | 'J' => 'Journal', |
||
| 108 | 'B' => 'Book', |
||
| 109 | 'S' => 'Series', |
||
| 110 | 'P' => 'Patent' |
||
| 111 | ]; |
||
| 112 | |||
| 113 | /** |
||
| 114 | * Gets the full tag name |
||
| 115 | * |
||
| 116 | * @param string $tag |
||
| 117 | */ |
||
| 118 | public static function tagToTagName($tag) |
||
| 121 | } |
||
| 122 | |||
| 123 | /** |
||
| 124 | * @param string $filePath |
||
| 125 | * @return array |
||
| 126 | */ |
||
| 127 | protected function readFile($filePath, $contentOnly = false) |
||
| 212 | } |
||
| 213 | |||
| 214 | public function createRisRecords() { |
||
| 215 | |||
| 216 | } |
||
| 217 | |||
| 218 | public function parseFile($filePath, $contentOnly = false) |
||
| 281 | } |
||
| 282 | |||
| 283 | /** |
||
| 284 | * @param array $risRecord |
||
| 285 | */ |
||
| 286 | public function risRecordToXML($risRecord) |
||
| 317 | } |