| Conditions | 111 | 
| Paths | > 20000 | 
| Total Lines | 562 | 
| Code Lines | 322 | 
| Lines | 36 | 
| Ratio | 6.41 % | 
| Changes | 38 | ||
| Bugs | 2 | Features | 7 | 
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 | ||
| 142 | public function getItem($pk = null) | ||
| 143 | 	{ | ||
| 144 | if (!isset($this->item)) | ||
| 145 | 		{ | ||
| 146 | $conf = JFactory::getConfig(); | ||
| 147 | 			$caching = $conf->get('caching') >= 1; | ||
| 148 | |||
| 149 | if ($caching) | ||
| 150 | 			{ | ||
| 151 | 				$keycache   = $this->getState('translation.client') . '.' . $this->getState('translation.tag') . '.' . | ||
| 152 | 					$this->getState('translation.filename') . '.' . 'translation'; | ||
| 153 | 				$cache      = JFactory::getCache('com_localise', ''); | ||
| 154 | $this->item = $cache->get($keycache); | ||
| 155 | |||
| 156 | 				if ($this->item && $this->item->reference != $this->getState('translation.reference')) | ||
| 157 | 				{ | ||
| 158 | $this->item = null; | ||
| 159 | } | ||
| 160 | } | ||
| 161 | else | ||
| 162 | 			{ | ||
| 163 | $this->item = null; | ||
| 164 | } | ||
| 165 | |||
| 166 | if (!$this->item) | ||
| 167 | 			{ | ||
| 168 | 				$path = JFile::exists($this->getState('translation.path')) | ||
| 169 | 					? $this->getState('translation.path') | ||
| 170 | 					: $this->getState('translation.refpath'); | ||
| 171 | |||
| 172 | 				$params              = JComponentHelper::getParams('com_localise'); | ||
| 173 | 				$allow_develop       = $params->get('gh_allow_develop', 0); | ||
| 174 | 				$gh_client           = $this->getState('translation.client'); | ||
| 175 | 				$tag                 = $this->getState('translation.tag'); | ||
| 176 | 				$reftag              = $this->getState('translation.reference'); | ||
| 177 | 				$refpath             = $this->getState('translation.refpath'); | ||
| 178 | $istranslation = 0; | ||
| 179 | |||
| 180 | if (!empty($tag) && $tag != $reftag) | ||
| 181 | 				{ | ||
| 182 | $istranslation = 1; | ||
| 183 | } | ||
| 184 | |||
| 185 | 				$this->setState('translation.translatedkeys', array()); | ||
| 186 | 				$this->setState('translation.untranslatedkeys', array()); | ||
| 187 | 				$this->setState('translation.unchangedkeys', array()); | ||
| 188 | 				$this->setState('translation.textchangedkeys', array()); | ||
| 189 | 				$this->setState('translation.revisedchanges', array()); | ||
| 190 | 				$this->setState('translation.developdata', array()); | ||
| 191 | |||
| 192 | 				$translatedkeys   = $this->getState('translation.translatedkeys'); | ||
| 193 | 				$untranslatedkeys = $this->getState('translation.untranslatedkeys'); | ||
| 194 | 				$unchangedkeys    = $this->getState('translation.unchangedkeys'); | ||
| 195 | 				$textchangedkeys  = $this->getState('translation.textchangedkeys'); | ||
| 196 | 				$revisedchanges  = $this->getState('translation.revisedchanges'); | ||
| 197 | 				$developdata      = $this->getState('translation.developdata'); | ||
| 198 | |||
| 199 | $this->item = new JObject( | ||
| 200 | array | ||
| 201 | ( | ||
| 202 | 										'reference'           => $this->getState('translation.reference'), | ||
| 203 | 'bom' => 'UTF-8', | ||
| 204 | 'svn' => '', | ||
| 205 | 'version' => '', | ||
| 206 | 'description' => '', | ||
| 207 | 'creationdate' => '', | ||
| 208 | 'author' => '', | ||
| 209 | 'maincopyright' => '', | ||
| 210 | 'additionalcopyright' => array(), | ||
| 211 | 'license' => '', | ||
| 212 | 										'exists'              => JFile::exists($this->getState('translation.path')), | ||
| 213 | 'istranslation' => $istranslation, | ||
| 214 | 'developdata' => (array) $developdata, | ||
| 215 | 'translatedkeys' => (array) $translatedkeys, | ||
| 216 | 'untranslatedkeys' => (array) $untranslatedkeys, | ||
| 217 | 'unchangedkeys' => (array) $unchangedkeys, | ||
| 218 | 'textchangedkeys' => (array) $textchangedkeys, | ||
| 219 | 'revisedchanges' => (array) $revisedchanges, | ||
| 220 | 'unrevised' => 0, | ||
| 221 | 'translatednews' => 0, | ||
| 222 | 'unchangednews' => 0, | ||
| 223 | 'translated' => 0, | ||
| 224 | 'untranslated' => 0, | ||
| 225 | 'unchanged' => 0, | ||
| 226 | 'extra' => 0, | ||
| 227 | 'total' => 0, | ||
| 228 | 'linespath' => 0, | ||
| 229 | 'linesrefpath' => 0, | ||
| 230 | 'linesdevpath' => 0, | ||
| 231 | 'linescustompath' => 0, | ||
| 232 | 'complete' => false, | ||
| 233 | 'source' => '', | ||
| 234 | 'error' => array() | ||
| 235 | ) | ||
| 236 | ); | ||
| 237 | |||
| 238 | if (JFile::exists($path)) | ||
| 239 | 				{ | ||
| 240 | $devpath = LocaliseHelper::searchDevpath($gh_client, $refpath); | ||
| 241 | $custompath = LocaliseHelper::searchCustompath($gh_client, $refpath); | ||
| 242 | |||
| 243 | if ($istranslation == 0 && $reftag == 'en-GB') | ||
| 244 | 					{ | ||
| 245 | if (!empty($devpath)) | ||
| 246 | 						{ | ||
| 247 | if (!empty($custompath)) | ||
| 248 | 							{ | ||
| 249 | $this->item->source = LocaliseHelper::combineReferences($custompath, $devpath); | ||
| 250 | } | ||
| 251 | else | ||
| 252 | 							{ | ||
| 253 | $this->item->source = LocaliseHelper::combineReferences($path, $devpath); | ||
| 254 | } | ||
| 255 | } | ||
| 256 | } | ||
| 257 | else | ||
| 258 | 					{ | ||
| 259 | $this->item->source = file_get_contents($path); | ||
| 260 | } | ||
| 261 | |||
| 262 | $stream = new JStream; | ||
| 263 | $stream->open($path); | ||
| 264 | $begin = $stream->read(4); | ||
| 265 | $bom = strtolower(bin2hex($begin)); | ||
| 266 | |||
| 267 | if ($bom == '0000feff') | ||
| 268 | 					{ | ||
| 269 | $this->item->bom = 'UTF-32 BE'; | ||
| 270 | } | ||
| 271 | else | ||
| 272 | 					{ | ||
| 273 | if ($bom == 'feff0000') | ||
| 274 | 						{ | ||
| 275 | $this->item->bom = 'UTF-32 LE'; | ||
| 276 | } | ||
| 277 | else | ||
| 278 | 						{ | ||
| 279 | if (substr($bom, 0, 4) == 'feff') | ||
| 280 | 							{ | ||
| 281 | $this->item->bom = 'UTF-16 BE'; | ||
| 282 | } | ||
| 283 | else | ||
| 284 | 							{ | ||
| 285 | if (substr($bom, 0, 4) == 'fffe') | ||
| 286 | 								{ | ||
| 287 | $this->item->bom = 'UTF-16 LE'; | ||
| 288 | } | ||
| 289 | } | ||
| 290 | } | ||
| 291 | } | ||
| 292 | |||
| 293 | $stream->seek(0); | ||
| 294 | $continue = true; | ||
|  | |||
| 295 | $lineNumber = 0; | ||
| 296 | |||
| 297 | 					$isTranslationsView = JFactory::getApplication()->input->get('view') == 'translations'; | ||
| 298 | |||
| 299 | while (!$stream->eof()) | ||
| 300 | 					{ | ||
| 301 | $line = $stream->gets(); | ||
| 302 | $lineNumber++; | ||
| 303 | |||
| 304 | if ($line[0] == '#') | ||
| 305 | 						{ | ||
| 306 | $this->item->error[] = $lineNumber; | ||
| 307 | } | ||
| 308 | elseif ($line[0] == ';') | ||
| 309 | 						{ | ||
| 310 | 							if (preg_match('/^(;).*(\$Id.*\$)/', $line, $matches)) | ||
| 311 | 							{ | ||
| 312 | $this->item->svn = $matches[2]; | ||
| 313 | } | ||
| 314 | 							elseif (preg_match('/(;)\s*@?(\pL+):?.*/', $line, $matches)) | ||
| 315 | 							{ | ||
| 316 | switch (strtolower($matches[2])) | ||
| 317 | 								{ | ||
| 318 | case 'note': | ||
| 319 | 										preg_match('/(;)\s*@?(\pL+):?\s+(.*)/', $line, $matches2); | ||
| 320 | $this->item->complete = $this->item->complete || strtolower($matches2[3]) == 'complete'; | ||
| 321 | break; | ||
| 322 | case 'version': | ||
| 323 | 										preg_match('/(;)\s*@?(\pL+):?\s+(.*)/', $line, $matches2); | ||
| 324 | $this->item->version = $matches2[3]; | ||
| 325 | break; | ||
| 326 | case 'desc': | ||
| 327 | case 'description': | ||
| 328 | 										preg_match('/(;)\s*@?(\pL+):?\s+(.*)/', $line, $matches2); | ||
| 329 | $this->item->description = $matches2[3]; | ||
| 330 | break; | ||
| 331 | case 'date': | ||
| 332 | 										preg_match('/(;)\s*@?(\pL+):?\s+(.*)/', $line, $matches2); | ||
| 333 | $this->item->creationdate = $matches2[3]; | ||
| 334 | break; | ||
| 335 | View Code Duplication | case 'author': | |
| 336 | 										if ($params->get('author') && !$isTranslationsView) | ||
| 337 | 										{ | ||
| 338 | 											$this->item->author = $params->get('author'); | ||
| 339 | } | ||
| 340 | else | ||
| 341 | 										{ | ||
| 342 | 											preg_match('/(;)\s*@?(\pL+):?\s+(.*)/', $line, $matches2); | ||
| 343 | $this->item->author = $matches2[3]; | ||
| 344 | } | ||
| 345 | break; | ||
| 346 | case 'copyright': | ||
| 347 | 										preg_match('/(;)\s*@?(\pL+):?\s+(.*)/', $line, $matches2); | ||
| 348 | |||
| 349 | if (empty($this->item->maincopyright)) | ||
| 350 | 										{ | ||
| 351 | 											if ($params->get('copyright') && !$isTranslationsView) | ||
| 352 | 											{ | ||
| 353 | 												$this->item->maincopyright = $params->get('copyright'); | ||
| 354 | } | ||
| 355 | else | ||
| 356 | 											{ | ||
| 357 | $this->item->maincopyright = $matches2[3]; | ||
| 358 | } | ||
| 359 | } | ||
| 360 | |||
| 361 | if (empty($this->item->additionalcopyright)) | ||
| 362 | 										{ | ||
| 363 | 											if ($params->get('additionalcopyright') && !$isTranslationsView) | ||
| 364 | 											{ | ||
| 365 | 												$this->item->additionalcopyright[] = $params->get('additionalcopyright'); | ||
| 366 | } | ||
| 367 | else | ||
| 368 | 											{ | ||
| 369 | $this->item->additionalcopyright[] = $matches2[3]; | ||
| 370 | } | ||
| 371 | } | ||
| 372 | break; | ||
| 373 | View Code Duplication | case 'license': | |
| 374 | 										if ($params->get('license') && !$isTranslationsView) | ||
| 375 | 										{ | ||
| 376 | 											$this->item->license = $params->get('license'); | ||
| 377 | } | ||
| 378 | else | ||
| 379 | 										{ | ||
| 380 | 											preg_match('/(;)\s*@?(\pL+):?\s+(.*)/', $line, $matches2); | ||
| 381 | $this->item->license = $matches2[3]; | ||
| 382 | } | ||
| 383 | break; | ||
| 384 | case 'package': | ||
| 385 | 										preg_match('/(;)\s*@?(\pL+):?\s+(.*)/', $line, $matches2); | ||
| 386 | $this->item->package = $matches2[3]; | ||
| 387 | break; | ||
| 388 | case 'subpackage': | ||
| 389 | 										preg_match('/(;)\s*@?(\pL+):?\s+(.*)/', $line, $matches2); | ||
| 390 | $this->item->subpackage = $matches2[3]; | ||
| 391 | break; | ||
| 392 | case 'link': | ||
| 393 | break; | ||
| 394 | View Code Duplication | default: | |
| 395 | if (empty($this->item->author)) | ||
| 396 | 										{ | ||
| 397 | 											if ($params->get('author') && !$isTranslationsView) | ||
| 398 | 											{ | ||
| 399 | 												$this->item->author = $params->get('author'); | ||
| 400 | } | ||
| 401 | else | ||
| 402 | 											{ | ||
| 403 | 												preg_match('/(;)\s*(.*)/', $line, $matches2); | ||
| 404 | $this->item->author = $matches2[2]; | ||
| 405 | } | ||
| 406 | } | ||
| 407 | break; | ||
| 408 | } | ||
| 409 | } | ||
| 410 | } | ||
| 411 | else | ||
| 412 | 						{ | ||
| 413 | break; | ||
| 414 | } | ||
| 415 | } | ||
| 416 | |||
| 417 | 					if (empty($this->item->author) && $params->get('author') && !$isTranslationsView) | ||
| 418 | 					{ | ||
| 419 | 						$this->item->author = $params->get('author'); | ||
| 420 | } | ||
| 421 | |||
| 422 | 					if (empty($this->item->license) && $params->get('license') && !$isTranslationsView) | ||
| 423 | 					{ | ||
| 424 | 						$this->item->license = $params->get('license'); | ||
| 425 | } | ||
| 426 | |||
| 427 | 					if (empty($this->item->maincopyright) && $params->get('copyright') && !$isTranslationsView) | ||
| 428 | 					{ | ||
| 429 | 						$this->item->maincopyright = $params->get('copyright'); | ||
| 430 | } | ||
| 431 | |||
| 432 | 					if (empty($this->item->additionalcopyright) && $params->get('additionalcopyright') && !$isTranslationsView) | ||
| 433 | 					{ | ||
| 434 | 						$this->item->additionalcopyright[] = $params->get('additionalcopyright'); | ||
| 435 | } | ||
| 436 | |||
| 437 | while (!$stream->eof()) | ||
| 438 | 					{ | ||
| 439 | $line = $stream->gets(); | ||
| 440 | $lineNumber++; | ||
| 441 | |||
| 442 | 						if (!preg_match('/^(|(\[[^\]]*\])|([A-Z][A-Z0-9_\*\-\.]*\s*=(\s*(("[^"]*")|(_QQ_)))+))\s*(;.*)?$/', $line)) | ||
| 443 | 						{ | ||
| 444 | $this->item->error[] = $lineNumber; | ||
| 445 | } | ||
| 446 | } | ||
| 447 | |||
| 448 | if ($tag != $reftag) | ||
| 449 | 					{ | ||
| 450 | if (JFile::exists($custompath)) | ||
| 451 | 						{ | ||
| 452 | $this->item->linescustompath = count(file($custompath)); | ||
| 453 | } | ||
| 454 | } | ||
| 455 | |||
| 456 | $stream->close(); | ||
| 457 | } | ||
| 458 | |||
| 459 | 				$this->item->additionalcopyright = implode("\n", $this->item->additionalcopyright); | ||
| 460 | |||
| 461 | 				if ($this->getState('translation.layout') != 'raw' && empty($this->item->error)) | ||
| 462 | 				{ | ||
| 463 | 					$sections = LocaliseHelper::parseSections($this->getState('translation.path')); | ||
| 464 | |||
| 465 | if (!empty($custompath)) | ||
| 466 | 						{ | ||
| 467 | $refsections = LocaliseHelper::parseSections($custompath); | ||
| 468 | } | ||
| 469 | else | ||
| 470 | 						{ | ||
| 471 | 							$refsections = LocaliseHelper::parseSections($this->getState('translation.refpath')); | ||
| 472 | } | ||
| 473 | |||
| 474 | $develop_client_path = JPATH_ROOT | ||
| 475 | . '/media/com_localise/develop/github/joomla-cms/en-GB/' | ||
| 476 | . $gh_client; | ||
| 477 | $develop_client_path = JFolder::makeSafe($develop_client_path); | ||
| 478 | 					$ref_file            = basename($this->getState('translation.refpath')); | ||
| 479 | $develop_file_path = "$develop_client_path/$ref_file"; | ||
| 480 | $new_keys = array(); | ||
| 481 | |||
| 482 | if (JFile::exists($develop_file_path) && $allow_develop == 1 && $reftag == 'en-GB') | ||
| 483 | 					{ | ||
| 484 | $info = array(); | ||
| 485 | $info['client'] = $gh_client; | ||
| 486 | $info['reftag'] = 'en-GB'; | ||
| 487 | $info['tag'] = 'en-GB'; | ||
| 488 | $info['filename'] = $ref_file; | ||
| 489 | $info['istranslation'] = $istranslation; | ||
| 490 | |||
| 491 | $develop_sections = LocaliseHelper::parseSections($develop_file_path); | ||
| 492 | $developdata = LocaliseHelper::getDevelopchanges($info, $refsections, $develop_sections); | ||
| 493 | $developdata['develop_file_path'] = ''; | ||
| 494 | |||
| 495 | if ($developdata['extra_keys']['amount'] > 0 || $developdata['text_changes']['amount'] > 0) | ||
| 496 | 						{ | ||
| 497 | if ($developdata['extra_keys']['amount'] > 0) | ||
| 498 | 							{ | ||
| 499 | $new_keys = $developdata['extra_keys']['keys']; | ||
| 500 | } | ||
| 501 | |||
| 502 | if ($developdata['text_changes']['amount'] > 0) | ||
| 503 | 							{ | ||
| 504 | $textchangedkeys = $developdata['text_changes']['keys']; | ||
| 505 | $this->item->textchangedkeys = $textchangedkeys; | ||
| 506 | 								$this->setState('translation.textchangedkeys', $textchangedkeys); | ||
| 507 | |||
| 508 | $changesdata['client'] = $gh_client; | ||
| 509 | $changesdata['reftag'] = $reftag; | ||
| 510 | |||
| 511 | if ($istranslation == 0) | ||
| 512 | 									{ | ||
| 513 | $changesdata['tag'] = $reftag; | ||
| 514 | } | ||
| 515 | else | ||
| 516 | 									{ | ||
| 517 | $changesdata['tag'] = $tag; | ||
| 518 | } | ||
| 519 | |||
| 520 | $changesdata['filename'] = $ref_file; | ||
| 521 | |||
| 522 | foreach ($textchangedkeys as $key_changed) | ||
| 523 | 								{ | ||
| 524 | $target_text = $developdata['text_changes']['ref_in_dev'][$key_changed]; | ||
| 525 | $source_text = $developdata['text_changes']['ref'][$key_changed]; | ||
| 526 | |||
| 527 | $changesdata['revised'] = '0'; | ||
| 528 | $changesdata['key'] = $key_changed; | ||
| 529 | $changesdata['target_text'] = $target_text; | ||
| 530 | $changesdata['source_text'] = $source_text; | ||
| 531 | $changesdata['istranslation'] = $istranslation; | ||
| 532 | $changesdata['catch_grammar'] = '0'; | ||
| 533 | |||
| 534 | $change_status = LocaliseHelper::searchRevisedvalue($changesdata); | ||
| 535 | $revisedchanges[$key_changed] = $change_status; | ||
| 536 | |||
| 537 | if ($change_status == 1) | ||
| 538 | 									{ | ||
| 539 | $developdata['text_changes']['revised']++; | ||
| 540 | } | ||
| 541 | else | ||
| 542 | 									{ | ||
| 543 | $developdata['text_changes']['unrevised']++; | ||
| 544 | } | ||
| 545 | } | ||
| 546 | |||
| 547 | $this->item->revisedchanges = $revisedchanges; | ||
| 548 | 								$this->setState('translation.revisedchanges', $revisedchanges); | ||
| 549 | } | ||
| 550 | |||
| 551 | // When develop changes are present, replace the reference keys | ||
| 552 | $refsections = $develop_sections; | ||
| 553 | |||
| 554 | // And store the path for future calls | ||
| 555 | $developdata['develop_file_path'] = $develop_file_path; | ||
| 556 | } | ||
| 557 | } | ||
| 558 | |||
| 559 | if (!empty($refsections['keys'])) | ||
| 560 | 					{ | ||
| 561 | foreach ($refsections['keys'] as $key => $string) | ||
| 562 | 						{ | ||
| 563 | $this->item->total++; | ||
| 564 | |||
| 565 | if (!empty($sections['keys']) && array_key_exists($key, $sections['keys']) && $sections['keys'][$key] != '') | ||
| 566 | 							{ | ||
| 567 | if ($sections['keys'][$key] != $string && $istranslation == 1) | ||
| 568 | 								{ | ||
| 569 | if (array_key_exists($key, $revisedchanges) && $revisedchanges[$key] == 0) | ||
| 570 | 									{ | ||
| 571 | $this->item->unrevised++; | ||
| 572 | $translatedkeys[] = $key; | ||
| 573 | } | ||
| 574 | elseif (in_array($key, $new_keys)) | ||
| 575 | 									{ | ||
| 576 | $this->item->translatednews++; | ||
| 577 | $translatedkeys[] = $key; | ||
| 578 | } | ||
| 579 | else | ||
| 580 | 									{ | ||
| 581 | $this->item->translated++; | ||
| 582 | $translatedkeys[] = $key; | ||
| 583 | } | ||
| 584 | } | ||
| 585 | elseif ($istranslation == 0) | ||
| 586 | 								{ | ||
| 587 | if (array_key_exists($key, $revisedchanges) && $revisedchanges[$key] == 0) | ||
| 588 | 									{ | ||
| 589 | $this->item->unrevised++; | ||
| 590 | } | ||
| 591 | elseif (in_array($key, $new_keys)) | ||
| 592 | 									{ | ||
| 593 | $untranslatedkeys[] = $key; | ||
| 594 | } | ||
| 595 | |||
| 596 | $this->item->translated++; | ||
| 597 | } | ||
| 598 | else | ||
| 599 | 								{ | ||
| 600 | if (in_array($key, $new_keys)) | ||
| 601 | 									{ | ||
| 602 | $this->item->unchangednews++; | ||
| 603 | } | ||
| 604 | else | ||
| 605 | 									{ | ||
| 606 | $this->item->unchanged++; | ||
| 607 | } | ||
| 608 | |||
| 609 | $unchangedkeys[] = $key; | ||
| 610 | } | ||
| 611 | } | ||
| 612 | elseif (!array_key_exists($key, $sections['keys'])) | ||
| 613 | 							{ | ||
| 614 | $this->item->untranslated++; | ||
| 615 | $untranslatedkeys[] = $key; | ||
| 616 | } | ||
| 617 | } | ||
| 618 | } | ||
| 619 | |||
| 620 | $this->item->translatedkeys = $translatedkeys; | ||
| 621 | $this->item->untranslatedkeys = $untranslatedkeys; | ||
| 622 | $this->item->unchangedkeys = $unchangedkeys; | ||
| 623 | $this->item->developdata = $developdata; | ||
| 624 | |||
| 625 | 					$this->setState('translation.translatedkeys', $translatedkeys); | ||
| 626 | 					$this->setState('translation.untranslatedkeys', $untranslatedkeys); | ||
| 627 | 					$this->setState('translation.unchangedkeys', $unchangedkeys); | ||
| 628 | 					$this->setState('translation.developdata', $developdata); | ||
| 629 | |||
| 630 | if (!empty($sections['keys']) && $istranslation == 1) | ||
| 631 | 					{ | ||
| 632 | foreach ($sections['keys'] as $key => $string) | ||
| 633 | 						{ | ||
| 634 | if (empty($refsections['keys']) || !array_key_exists($key, $refsections['keys'])) | ||
| 635 | 							{ | ||
| 636 | $this->item->extra++; | ||
| 637 | } | ||
| 638 | } | ||
| 639 | } | ||
| 640 | |||
| 641 | $done = $this->item->translated + $this->item->translatednews + $this->item->unchangednews; | ||
| 642 | |||
| 643 | $this->item->completed = $this->item->total | ||
| 644 | ? intval(100 * $done / $this->item->total) | ||
| 645 | : 100; | ||
| 646 | |||
| 647 | $this->item->complete = $this->item->complete == 1 && $this->item->untranslated == 0 && $this->item->unrevised == 0 | ||
| 648 | ? 1 | ||
| 649 | : ($this->item->completed == 100 | ||
| 650 | ? 1 | ||
| 651 | : 0); | ||
| 652 | } | ||
| 653 | |||
| 654 | 				if ($this->getState('translation.id')) | ||
| 655 | 				{ | ||
| 656 | $table = $this->getTable(); | ||
| 657 | 					$table->load($this->getState('translation.id')); | ||
| 658 | $user = JFactory::getUser($table->checked_out); | ||
| 659 | $this->item->setProperties($table->getProperties()); | ||
| 660 | |||
| 661 | if ($this->item->checked_out == JFactory::getUser()->id) | ||
| 662 | 					{ | ||
| 663 | $this->item->checked_out = 0; | ||
| 664 | } | ||
| 665 | |||
| 666 | 					$this->item->editor = JText::sprintf('COM_LOCALISE_TEXT_TRANSLATION_EDITOR', $user->name, $user->username); | ||
| 667 | } | ||
| 668 | |||
| 669 | if ($caching) | ||
| 670 | 				{ | ||
| 671 | $cache->store($this->item, $keycache); | ||
| 672 | } | ||
| 673 | |||
| 674 | // Count the number of lines in the ini file to check max_input_vars | ||
| 675 | if ($tag != $reftag) | ||
| 676 | 				{ | ||
| 677 | if (JFile::exists($path)) | ||
| 678 | 					{ | ||
| 679 | $this->item->linespath = count(file($path)); | ||
| 680 | } | ||
| 681 | |||
| 682 | if (JFile::exists($refpath)) | ||
| 683 | 					{ | ||
| 684 | $this->item->linesrefpath = count(file($refpath)); | ||
| 685 | } | ||
| 686 | |||
| 687 | if (JFile::exists($develop_file_path)) | ||
| 688 | 					{ | ||
| 689 | $this->item->linesdevpath = count(file($develop_file_path)); | ||
| 690 | } | ||
| 691 | } | ||
| 692 | else | ||
| 693 | 				{ | ||
| 694 | if (JFile::exists($path)) | ||
| 695 | 					{ | ||
| 696 | $this->item->linespath = count(file($path)); | ||
| 697 | } | ||
| 698 | } | ||
| 699 | } | ||
| 700 | } | ||
| 701 | |||
| 702 | return $this->item; | ||
| 703 | } | ||
| 704 | |||
| 1561 | 
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.