| Conditions | 4 |
| Paths | 4 |
| Total Lines | 293 |
| Code Lines | 274 |
| Lines | 15 |
| Ratio | 5.12 % |
| 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 |
||
| 115 | public function __construct($fedname = "") { |
||
| 116 | |||
| 117 | // initialise the superclass variables |
||
| 118 | |||
| 119 | $this->databaseType = "INST"; |
||
| 120 | $this->entityOptionTable = "federation_option"; |
||
| 121 | $this->entityIdColumn = "federation_id"; |
||
| 122 | $this->identifier = $fedname; |
||
| 123 | $this->name = $fedname; |
||
| 124 | $this->attributes = []; |
||
| 125 | |||
| 126 | /* Federations are created in DB with bootstrapFederation, and listed via listFederations |
||
| 127 | */ |
||
| 128 | $oldlocale = CAT::set_locale('core'); |
||
| 129 | |||
| 130 | Federation::$FederationList = [ |
||
| 131 | 'AD' => _("Andorra"), |
||
| 132 | 'AT' => _("Austria"), |
||
| 133 | 'BE' => _("Belgium"), |
||
| 134 | 'BG' => _("Bulgaria"), |
||
| 135 | 'CY' => _("Cyprus"), |
||
| 136 | 'CZ' => _("Czech Republic"), |
||
| 137 | 'DK' => _("Denmark"), |
||
| 138 | 'EE' => _("Estonia"), |
||
| 139 | 'FI' => _("Finland"), |
||
| 140 | 'FR' => _("France"), |
||
| 141 | 'DE' => _("Germany"), |
||
| 142 | 'GR' => _("Greece"), |
||
| 143 | 'HR' => _("Croatia"), |
||
| 144 | 'IE' => _("Ireland"), |
||
| 145 | 'IS' => _("Iceland"), |
||
| 146 | 'IT' => _("Italy"), |
||
| 147 | 'HU' => _("Hungary"), |
||
| 148 | 'LU' => _("Luxembourg"), |
||
| 149 | 'LV' => _("Latvia"), |
||
| 150 | 'LT' => _("Lithuania"), |
||
| 151 | 'MK' => _("Macedonia"), |
||
| 152 | 'RS' => _("Serbia"), |
||
| 153 | 'NL' => _("Netherlands"), |
||
| 154 | 'NO' => _("Norway"), |
||
| 155 | 'PL' => _("Poland"), |
||
| 156 | 'PT' => _("Portugal"), |
||
| 157 | 'RO' => _("Romania"), |
||
| 158 | 'SI' => _("Slovenia"), |
||
| 159 | 'ES' => _("Spain"), |
||
| 160 | 'SE' => _("Sweden"), |
||
| 161 | 'SK' => _("Slovakia"), |
||
| 162 | 'CH' => _("Switzerland"), |
||
| 163 | 'TR' => _("Turkey"), |
||
| 164 | 'UK' => _("United Kingdom"), |
||
| 165 | 'TEST' => 'TEST Country', |
||
| 166 | 'AU' => _("Australia"), |
||
| 167 | 'CA' => _("Canada"), |
||
| 168 | 'IL' => _("Israel"), |
||
| 169 | 'JP' => _("Japan"), |
||
| 170 | 'NZ' => _("New Zealand"), |
||
| 171 | 'US' => _("U.S.A."), |
||
| 172 | 'BR' => _("Brazil"), |
||
| 173 | 'CL' => _("Chile"), |
||
| 174 | 'PE' => _("Peru"), |
||
| 175 | 'VE' => _("Venezuela"), |
||
| 176 | 'DEFAULT' => _("Default"), |
||
| 177 | 'AM' => _("Armenia"), |
||
| 178 | 'AZ' => _("Azerbaijan"), |
||
| 179 | 'BY' => _("Belarus"), |
||
| 180 | 'EC' => _("Ecuador"), |
||
| 181 | 'HK' => _("Hong Kong"), |
||
| 182 | 'KE' => _("Kenya"), |
||
| 183 | 'KG' => _("Kyrgyzstan"), |
||
| 184 | 'KR' => _("Korea"), |
||
| 185 | 'KZ' => _("Kazakhstan"), |
||
| 186 | 'MA' => _("Morocco"), |
||
| 187 | 'MD' => _("Moldova"), |
||
| 188 | 'ME' => _("Montenegro"), |
||
| 189 | 'MO' => _("Macau"), |
||
| 190 | 'MT' => _("Malta"), |
||
| 191 | 'RU' => _("Russia"), |
||
| 192 | 'SG' => _("Singapore"), |
||
| 193 | 'TH' => _("Thailand"), |
||
| 194 | 'TW' => _("Taiwan"), |
||
| 195 | 'ZA' => _("South Africa"), |
||
| 196 | 'AF' => 'Afghanistan', |
||
| 197 | 'AL' => 'Albania', |
||
| 198 | 'DZ' => 'Algeria', |
||
| 199 | 'AS' => 'American Samoa', |
||
| 200 | 'AO' => 'Angola', |
||
| 201 | 'AI' => 'Anguilla', |
||
| 202 | 'AQ' => 'Antarctica', |
||
| 203 | 'AG' => 'Antigua And Barbuda', |
||
| 204 | 'AR' => 'Argentina', |
||
| 205 | 'AW' => 'Aruba', |
||
| 206 | 'BS' => 'Bahamas, The', |
||
| 207 | 'BH' => 'Bahrain', |
||
| 208 | 'BD' => 'Bangladesh', |
||
| 209 | 'BB' => 'Barbados', |
||
| 210 | 'BZ' => 'Belize', |
||
| 211 | 'BJ' => 'Benin', |
||
| 212 | 'BM' => 'Bermuda', |
||
| 213 | 'BT' => 'Bhutan', |
||
| 214 | 'BO' => 'Bolivia', |
||
| 215 | 'BA' => 'Bosnia And Herzegovina', |
||
| 216 | 'BW' => 'Botswana', |
||
| 217 | 'BV' => 'Bouvet Island', |
||
| 218 | 'IO' => 'British Indian Ocean Territory', |
||
| 219 | 'BN' => 'Brunei', |
||
| 220 | 'BF' => 'Burkina Faso', |
||
| 221 | 'MM' => 'Burma', |
||
| 222 | 'BI' => 'Burundi', |
||
| 223 | 'KH' => 'Cambodia', |
||
| 224 | 'CM' => 'Cameroon', |
||
| 225 | 'CV' => 'Cape Verde', |
||
| 226 | 'KY' => 'Cayman Islands', |
||
| 227 | 'CF' => 'Central African Republic', |
||
| 228 | 'TD' => 'Chad', |
||
| 229 | 'CN' => 'China', |
||
| 230 | 'CX' => 'Christmas Island', |
||
| 231 | 'CC' => 'Cocos (keeling) Islands', |
||
| 232 | 'CO' => 'Colombia', |
||
| 233 | 'KM' => 'Comoros', |
||
| 234 | 'CG' => 'Congo (brazzaville) ', |
||
| 235 | 'CD' => 'Congo (kinshasa)', |
||
| 236 | 'CK' => 'Cook Islands', |
||
| 237 | 'CR' => 'Costa Rica', |
||
| 238 | 'CI' => 'CÔte D’ivoire', |
||
| 239 | 'CU' => 'Cuba', |
||
| 240 | 'CW' => 'CuraÇao', |
||
| 241 | 'DJ' => 'Djibouti', |
||
| 242 | 'DM' => 'Dominica', |
||
| 243 | 'DO' => 'Dominican Republic', |
||
| 244 | 'EG' => 'Egypt', |
||
| 245 | 'SV' => 'El Salvador', |
||
| 246 | 'GQ' => 'Equatorial Guinea', |
||
| 247 | 'ER' => 'Eritrea', |
||
| 248 | 'ET' => 'Ethiopia', |
||
| 249 | 'FK' => 'Falkland Islands (islas Malvinas)', |
||
| 250 | 'FO' => 'Faroe Islands', |
||
| 251 | 'FJ' => 'Fiji', |
||
| 252 | 'GF' => 'French Guiana', |
||
| 253 | 'PF' => 'French Polynesia', |
||
| 254 | 'TF' => 'French Southern And Antarctic Lands', |
||
| 255 | 'GA' => 'Gabon', |
||
| 256 | 'GM' => 'Gambia, The', |
||
| 257 | 'GE' => 'Georgia', |
||
| 258 | 'GH' => 'Ghana', |
||
| 259 | 'GI' => 'Gibraltar', |
||
| 260 | 'GL' => 'Greenland', |
||
| 261 | 'GD' => 'Grenada', |
||
| 262 | 'GP' => 'Guadeloupe', |
||
| 263 | 'GU' => 'Guam', |
||
| 264 | 'GT' => 'Guatemala', |
||
| 265 | 'GG' => 'Guernsey', |
||
| 266 | 'GN' => 'Guinea', |
||
| 267 | 'GW' => 'Guinea-bissau', |
||
| 268 | 'GY' => 'Guyana', |
||
| 269 | 'HT' => 'Haiti', |
||
| 270 | 'HM' => 'Heard Island And Mcdonald Islands', |
||
| 271 | 'HN' => 'Honduras', |
||
| 272 | 'IN' => 'India', |
||
| 273 | 'ID' => 'Indonesia', |
||
| 274 | 'IR' => 'Iran', |
||
| 275 | 'IQ' => 'Iraq', |
||
| 276 | 'IM' => 'Isle Of Man', |
||
| 277 | 'JM' => 'Jamaica', |
||
| 278 | 'JE' => 'Jersey', |
||
| 279 | 'JO' => 'Jordan', |
||
| 280 | 'KI' => 'Kiribati', |
||
| 281 | 'KP' => 'Korea, North', |
||
| 282 | 'KW' => 'Kuwait', |
||
| 283 | 'LA' => 'Laos', |
||
| 284 | 'LB' => 'Lebanon', |
||
| 285 | 'LS' => 'Lesotho', |
||
| 286 | 'LR' => 'Liberia', |
||
| 287 | 'LY' => 'Libya', |
||
| 288 | 'LI' => 'Liechtenstein', |
||
| 289 | 'MG' => 'Madagascar', |
||
| 290 | 'MW' => 'Malawi', |
||
| 291 | 'MY' => 'Malaysia', |
||
| 292 | 'MV' => 'Maldives', |
||
| 293 | 'ML' => 'Mali', |
||
| 294 | 'MH' => 'Marshall Islands', |
||
| 295 | 'MQ' => 'Martinique', |
||
| 296 | 'MR' => 'Mauritania', |
||
| 297 | 'MU' => 'Mauritius', |
||
| 298 | 'YT' => 'Mayotte', |
||
| 299 | 'MX' => 'Mexico', |
||
| 300 | 'FM' => 'Micronesia, Federated States Of', |
||
| 301 | 'MC' => 'Monaco', |
||
| 302 | 'MN' => 'Mongolia', |
||
| 303 | 'MS' => 'Montserrat', |
||
| 304 | 'MZ' => 'Mozambique', |
||
| 305 | 'NA' => 'Namibia', |
||
| 306 | 'NR' => 'Nauru', |
||
| 307 | 'NP' => 'Nepal', |
||
| 308 | 'NC' => 'New Caledonia', |
||
| 309 | 'NI' => 'Nicaragua', |
||
| 310 | 'NE' => 'Niger', |
||
| 311 | 'NG' => 'Nigeria', |
||
| 312 | 'NU' => 'Niue', |
||
| 313 | 'NF' => 'Norfolk Island', |
||
| 314 | 'MP' => 'Northern Mariana Islands', |
||
| 315 | 'OM' => 'Oman', |
||
| 316 | 'PK' => 'Pakistan', |
||
| 317 | 'PW' => 'Palau', |
||
| 318 | 'PA' => 'Panama', |
||
| 319 | 'PG' => 'Papua New Guinea', |
||
| 320 | 'PY' => 'Paraguay', |
||
| 321 | 'PH' => 'Philippines', |
||
| 322 | 'PN' => 'Pitcairn Islands', |
||
| 323 | 'PR' => 'Puerto Rico', |
||
| 324 | 'QA' => 'Qatar', |
||
| 325 | 'RE' => 'Reunion', |
||
| 326 | 'RW' => 'Rwanda', |
||
| 327 | 'BL' => 'Saint Barthelemy', |
||
| 328 | 'SH' => 'Saint Helena, Ascension, And Tristan Da Cunha', |
||
| 329 | 'KN' => 'Saint Kitts And Nevis', |
||
| 330 | 'LC' => 'Saint Lucia', |
||
| 331 | 'MF' => 'Saint Martin', |
||
| 332 | 'PM' => 'Saint Pierre And Miquelon', |
||
| 333 | 'VC' => 'Saint Vincent And The Grenadines', |
||
| 334 | 'WS' => 'Samoa', |
||
| 335 | 'SM' => 'San Marino', |
||
| 336 | 'ST' => 'Sao Tome And Principe', |
||
| 337 | 'SA' => 'Saudi Arabia', |
||
| 338 | 'SN' => 'Senegal', |
||
| 339 | 'SC' => 'Seychelles', |
||
| 340 | 'SL' => 'Sierra Leone', |
||
| 341 | 'SX' => 'Sint Maarten', |
||
| 342 | 'SB' => 'Solomon Islands', |
||
| 343 | 'SO' => 'Somalia', |
||
| 344 | 'GS' => 'South Georgia And South Sandwich Islands', |
||
| 345 | 'SS' => 'South Sudan', |
||
| 346 | 'LK' => 'Sri Lanka', |
||
| 347 | 'SD' => 'Sudan', |
||
| 348 | 'SR' => 'Suriname', |
||
| 349 | 'SZ' => 'Swaziland', |
||
| 350 | 'SY' => 'Syria', |
||
| 351 | 'TJ' => 'Tajikistan', |
||
| 352 | 'TZ' => 'Tanzania', |
||
| 353 | 'TL' => 'Timor-leste', |
||
| 354 | 'TG' => 'Togo', |
||
| 355 | 'TK' => 'Tokelau', |
||
| 356 | 'TO' => 'Tonga', |
||
| 357 | 'TT' => 'Trinidad And Tobago', |
||
| 358 | 'TN' => 'Tunisia', |
||
| 359 | 'TM' => 'Turkmenistan', |
||
| 360 | 'TC' => 'Turks And Caicos Islands', |
||
| 361 | 'TV' => 'Tuvalu', |
||
| 362 | 'UG' => 'Uganda', |
||
| 363 | 'UA' => 'Ukraine', |
||
| 364 | 'AE' => 'United Arab Emirates', |
||
| 365 | 'GB' => 'United Kingdom', |
||
| 366 | 'UY' => 'Uruguay', |
||
| 367 | 'UZ' => 'Uzbekistan', |
||
| 368 | 'VU' => 'Vanuatu', |
||
| 369 | 'VA' => 'Vatican City', |
||
| 370 | 'VN' => 'Vietnam', |
||
| 371 | 'VG' => 'Virgin Islands, British', |
||
| 372 | 'VI' => 'Virgin Islands, United States ', |
||
| 373 | 'WF' => 'Wallis And Futuna', |
||
| 374 | 'EH' => 'Western Sahara', |
||
| 375 | 'YE' => 'Yemen', |
||
| 376 | 'ZM' => 'Zambia', |
||
| 377 | 'ZW' => 'Zimbabwe', |
||
| 378 | ]; |
||
| 379 | |||
| 380 | CAT::set_locale($oldlocale); |
||
| 381 | |||
| 382 | $fedAttributes = DBConnection::exec($this->databaseType, "SELECT DISTINCT option_name,option_value, row FROM federation_option |
||
| 383 | WHERE federation_id = '$this->name' ORDER BY option_name"); |
||
| 384 | |||
| 385 | $optioninstance = Options::instance(); |
||
| 386 | |||
| 387 | View Code Duplication | while ($queryResult = mysqli_fetch_object($fedAttributes)) { |
|
| 388 | $lang = ""; |
||
| 389 | // decode base64 for files (respecting multi-lang) |
||
| 390 | $optinfo = $optioninstance->optionType($queryResult->option_name); |
||
| 391 | $flag = $optinfo['flag']; |
||
| 392 | |||
| 393 | if ($optinfo['type'] != "file") { |
||
| 394 | $this->attributes[] = array("name" => $queryResult->option_name, "value" => $queryResult->option_value, "level" => "FED", "row" => $queryResult->row, "flag" => $flag); |
||
| 395 | } else { |
||
| 396 | |||
| 397 | $decodedAttribute = $this->decodeFileAttribute($queryResult->option_value); |
||
| 398 | |||
| 399 | $this->attributes[] = array("name" => $queryResult->option_name, "value" => ($decodedAttribute['lang'] == "" ? $decodedAttribute['content'] : serialize($decodedAttribute)), "level" => "FED", "row" => $queryResult->row, "flag" => $flag); |
||
| 400 | } |
||
| 401 | } |
||
| 402 | $this->attributes[] = array("name" => "internal:country", |
||
| 403 | "value" => $this->name, |
||
| 404 | "level" => "FED", |
||
| 405 | "row" => 0, |
||
| 406 | "flag" => NULL); |
||
| 407 | } |
||
| 408 | |||
| 648 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.