| Total Complexity | 88 |
| Total Lines | 651 |
| Duplicated Lines | 0 % |
| Changes | 7 | ||
| Bugs | 1 | Features | 0 |
Complex classes like TDMCreateHtmlSmartyCodes 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 TDMCreateHtmlSmartyCodes, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 28 | class TDMCreateHtmlSmartyCodes |
||
| 29 | { |
||
| 30 | /** |
||
| 31 | * @public function constructor |
||
| 32 | * @param null |
||
| 33 | */ |
||
| 34 | |||
| 35 | public function __construct() |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @static function getInstance |
||
| 41 | * @param null |
||
| 42 | * @return TDMCreateHtmlSmartyCodes |
||
| 43 | */ |
||
| 44 | public static function getInstance() |
||
| 53 | |||
| 54 | /** |
||
| 55 | * @public function getHtmlTag |
||
| 56 | * @param string $tag |
||
| 57 | * @param array $attributes |
||
| 58 | * @param string $content |
||
| 59 | * @param bool $noClosed |
||
| 60 | * |
||
| 61 | * @param string $t |
||
| 62 | * @return string |
||
| 63 | */ |
||
| 64 | public function getHtmlTag($tag = '', $attributes = [], $content = '', $noClosed = false, $t = '') |
||
| 80 | |||
| 81 | /** |
||
| 82 | * @private function setAttributes |
||
| 83 | * @param array $attributes |
||
| 84 | * |
||
| 85 | * @return string |
||
| 86 | */ |
||
| 87 | private function getAttributes($attributes) |
||
| 98 | |||
| 99 | /** |
||
| 100 | * @public function getHtmlEmpty |
||
| 101 | * @param string $empty |
||
| 102 | * |
||
| 103 | * @return string |
||
| 104 | */ |
||
| 105 | public function getHtmlEmpty($empty = '') |
||
| 109 | |||
| 110 | /** |
||
| 111 | * @public function getHtmlComment |
||
| 112 | * @param string $htmlComment |
||
| 113 | * |
||
| 114 | * @return string |
||
| 115 | */ |
||
| 116 | public function getHtmlComment($htmlComment = '') |
||
| 120 | |||
| 121 | /** |
||
| 122 | * @public function getHtmlBr |
||
| 123 | * @param int $brNumb |
||
| 124 | * @param string $htmlClass |
||
| 125 | * |
||
| 126 | * @param string $t |
||
| 127 | * @return string |
||
| 128 | */ |
||
| 129 | public function getHtmlBr($brNumb = 1, $htmlClass = '', $t = '') |
||
| 139 | |||
| 140 | /** |
||
| 141 | * @public function getHtmlHNumb |
||
| 142 | * @param string $content |
||
| 143 | * |
||
| 144 | * @param string $n |
||
| 145 | * @param string $htmlHClass |
||
| 146 | * @param string $t |
||
| 147 | * @return string |
||
| 148 | */ |
||
| 149 | public function getHtmlHNumb($content = '', $n = '1', $htmlHClass = '', $t = '') |
||
| 156 | |||
| 157 | /** |
||
| 158 | * @public function getHtmlDiv |
||
| 159 | * @param string $content |
||
| 160 | * |
||
| 161 | * @param string $divClass |
||
| 162 | * @param string $t |
||
| 163 | * @return string |
||
| 164 | */ |
||
| 165 | public function getHtmlDiv($content = '', $divClass = '', $t = '') |
||
| 174 | |||
| 175 | /** |
||
| 176 | * @public function getHtmlPre |
||
| 177 | * @param string $content |
||
| 178 | * |
||
| 179 | * @param string $preClass |
||
| 180 | * @param string $t |
||
| 181 | * @return string |
||
| 182 | */ |
||
| 183 | public function getHtmlPre($content = '', $preClass = '', $t = '') |
||
| 192 | |||
| 193 | /** |
||
| 194 | * @public function getHtmlSpan |
||
| 195 | * @param string $content |
||
| 196 | * |
||
| 197 | * @param string $spanClass |
||
| 198 | * @param string $t |
||
| 199 | * @return string |
||
| 200 | */ |
||
| 201 | public function getHtmlSpan($content = '', $spanClass = '', $t = '') |
||
| 208 | |||
| 209 | /** |
||
| 210 | * @public function getHtmlParagraph |
||
| 211 | * @param string $content |
||
| 212 | * |
||
| 213 | * @param string $pClass |
||
| 214 | * @param string $t |
||
| 215 | * @return string |
||
| 216 | */ |
||
| 217 | public function getHtmlParagraph($content = '', $pClass = '', $t = '') |
||
| 226 | |||
| 227 | /** |
||
| 228 | * @public function getHtmlI |
||
| 229 | * @param string $content |
||
| 230 | * |
||
| 231 | * @param string $iClass |
||
| 232 | * @param string $t |
||
| 233 | * @return string |
||
| 234 | */ |
||
| 235 | public function getHtmlI($content = '', $iClass = '', $t = '') |
||
| 242 | |||
| 243 | /** |
||
| 244 | * @public function getHtmlUl |
||
| 245 | * @param string $content |
||
| 246 | * |
||
| 247 | * @param string $ulClass |
||
| 248 | * @param string $t |
||
| 249 | * @return string |
||
| 250 | */ |
||
| 251 | public function getHtmlUl($content = '', $ulClass = '', $t = '') |
||
| 260 | |||
| 261 | /** |
||
| 262 | * @public function getHtmlOl |
||
| 263 | * @param string $content |
||
| 264 | * |
||
| 265 | * @param string $olClass |
||
| 266 | * @param string $t |
||
| 267 | * @return string |
||
| 268 | */ |
||
| 269 | public function getHtmlOl($content = '', $olClass = '', $t = '') |
||
| 278 | |||
| 279 | /** |
||
| 280 | * @public function getHtmlLi |
||
| 281 | * @param string $content |
||
| 282 | * @param string $liClass |
||
| 283 | * |
||
| 284 | * @param string $t |
||
| 285 | * @return string |
||
| 286 | */ |
||
| 287 | public function getHtmlLi($content = '', $liClass = '', $t = '') |
||
| 293 | |||
| 294 | /** |
||
| 295 | * @public function getHtmlStrong |
||
| 296 | * @param string $content |
||
| 297 | * @param string $strongClass |
||
| 298 | * |
||
| 299 | * @param string $t |
||
| 300 | * @return string |
||
| 301 | */ |
||
| 302 | public function getHtmlStrong($content = '', $strongClass = '', $t = '') |
||
| 308 | |||
| 309 | /** |
||
| 310 | * @public function getHtmlAnchor |
||
| 311 | * @param string $url |
||
| 312 | * @param string $content |
||
| 313 | * @param string $title |
||
| 314 | * @param string $target |
||
| 315 | * @param string $aClass |
||
| 316 | * |
||
| 317 | * @param string $rel |
||
| 318 | * @param string $t |
||
| 319 | * @return string |
||
| 320 | */ |
||
| 321 | public function getHtmlAnchor($url = '#', $content = ' ', $title = '', $target = '', $aClass = '', $rel = '', $t = '') |
||
| 329 | |||
| 330 | /** |
||
| 331 | * @public function getHtmlImage |
||
| 332 | * @param string $src |
||
| 333 | * @param string $alt |
||
| 334 | * @param string $imgClass |
||
| 335 | * |
||
| 336 | * @param string $t |
||
| 337 | * @return string |
||
| 338 | */ |
||
| 339 | public function getHtmlImage($src = 'blank.gif', $alt = 'blank.gif', $imgClass = '', $t = '') |
||
| 346 | |||
| 347 | /** |
||
| 348 | * @public function getHtmlTable |
||
| 349 | * @param string $content |
||
| 350 | * @param string $tableClass |
||
| 351 | * |
||
| 352 | * @param string $t |
||
| 353 | * @return string |
||
| 354 | */ |
||
| 355 | public function getHtmlTable($content = '', $tableClass = '', $t = '') |
||
| 364 | |||
| 365 | /** |
||
| 366 | * @public function getHtmlTableThead |
||
| 367 | * @param string $content |
||
| 368 | * @param string $theadClass |
||
| 369 | * |
||
| 370 | * @param string $t |
||
| 371 | * @return string |
||
| 372 | */ |
||
| 373 | public function getHtmlTableThead($content = '', $theadClass = '', $t = '') |
||
| 382 | |||
| 383 | /** |
||
| 384 | * @public function getHtmlTableTbody |
||
| 385 | * @param string $content |
||
| 386 | * @param string $tbodyClass |
||
| 387 | * |
||
| 388 | * @param string $t |
||
| 389 | * @return string |
||
| 390 | */ |
||
| 391 | public function getHtmlTableTbody($content = '', $tbodyClass = '', $t = '') |
||
| 400 | |||
| 401 | /** |
||
| 402 | * @public function getHtmlTableTfoot |
||
| 403 | * @param string $content |
||
| 404 | * @param string $tfootClass |
||
| 405 | * |
||
| 406 | * @param string $t |
||
| 407 | * @return string |
||
| 408 | */ |
||
| 409 | public function getHtmlTableTfoot($content = '', $tfootClass = '', $t = '') |
||
| 418 | |||
| 419 | /** |
||
| 420 | * @public function getHtmlTableRow |
||
| 421 | * @param string $content |
||
| 422 | * @param string $trClass |
||
| 423 | * |
||
| 424 | * @param string $t |
||
| 425 | * @return string |
||
| 426 | */ |
||
| 427 | public function getHtmlTableRow($content = '', $trClass = '', $t = '') |
||
| 436 | |||
| 437 | /** |
||
| 438 | * @public function getHtmlTableHead |
||
| 439 | * @param string $content |
||
| 440 | * @param string $thClass |
||
| 441 | * @param string $colspan |
||
| 442 | * |
||
| 443 | * @param string $t |
||
| 444 | * @return string |
||
| 445 | */ |
||
| 446 | public function getHtmlTableHead($content = '', $thClass = '', $colspan = '', $t = '') |
||
| 453 | |||
| 454 | /** |
||
| 455 | * @public function getHtmlTableData |
||
| 456 | * @param $content |
||
| 457 | * @param $tdClass |
||
| 458 | * @param $colspan |
||
| 459 | * |
||
| 460 | * @return string |
||
| 461 | */ |
||
| 462 | public function getHtmlTableData($content = '', $tdClass = '', $colspan = '') |
||
| 469 | |||
| 470 | /** |
||
| 471 | * @public function getSmartyComment |
||
| 472 | * @param string $comment |
||
| 473 | * |
||
| 474 | * @return string |
||
| 475 | */ |
||
| 476 | public function getSmartyComment($comment = '') |
||
| 480 | |||
| 481 | /** |
||
| 482 | * @public function getSmartyNoSimbol |
||
| 483 | * @param string $noSimbol |
||
| 484 | * |
||
| 485 | * @return string |
||
| 486 | */ |
||
| 487 | public function getSmartyNoSimbol($noSimbol = '') |
||
| 491 | |||
| 492 | /** |
||
| 493 | * @public function getSmartyConst |
||
| 494 | * @param string $language |
||
| 495 | * @param mixed $const |
||
| 496 | * |
||
| 497 | * @return string |
||
| 498 | */ |
||
| 499 | public function getSmartyConst($language, $const) |
||
| 503 | |||
| 504 | /** |
||
| 505 | * @public function getSmartySingleVar |
||
| 506 | * @param string $var |
||
| 507 | * |
||
| 508 | * @return string |
||
| 509 | */ |
||
| 510 | public function getSmartySingleVar($var) |
||
| 514 | |||
| 515 | /** |
||
| 516 | * @public function getSmartyDoubleVar |
||
| 517 | * @param string $leftVar |
||
| 518 | * @param string $rightVar |
||
| 519 | * |
||
| 520 | * @return string |
||
| 521 | */ |
||
| 522 | public function getSmartyDoubleVar($leftVar, $rightVar) |
||
| 526 | |||
| 527 | /** |
||
| 528 | * @public function getSmartyIncludeFile |
||
| 529 | * @param $moduleDirname |
||
| 530 | * @param string $fileName |
||
| 531 | * @param bool $admin |
||
| 532 | * |
||
| 533 | * @param bool $q |
||
| 534 | * @return string |
||
| 535 | */ |
||
| 536 | public function getSmartyIncludeFile($moduleDirname, $fileName = 'header', $admin = false, $q = false) |
||
| 550 | |||
| 551 | /** |
||
| 552 | * @public function getSmartyIncludeFileListSection |
||
| 553 | * @param $moduleDirname |
||
| 554 | * @param $fileName |
||
| 555 | * @param $tableFieldName |
||
| 556 | * |
||
| 557 | * @return string |
||
| 558 | */ |
||
| 559 | public function getSmartyIncludeFileListSection($moduleDirname, $fileName, $tableFieldName) |
||
| 563 | |||
| 564 | /** |
||
| 565 | * @public function getSmartyIncludeFileListForeach |
||
| 566 | * @param $moduleDirname |
||
| 567 | * @param $fileName |
||
| 568 | * @param $tableFieldName |
||
| 569 | * |
||
| 570 | * @return string |
||
| 571 | */ |
||
| 572 | public function getSmartyIncludeFileListForeach($moduleDirname, $fileName, $tableFieldName) |
||
| 576 | |||
| 577 | /** |
||
| 578 | * @public function getSmartyConditions |
||
| 579 | * @param string $condition |
||
| 580 | * @param string $operator |
||
| 581 | * @param string $type |
||
| 582 | * @param string $contentIf |
||
| 583 | * @param mixed $contentElse |
||
| 584 | * @param bool $count |
||
| 585 | * |
||
| 586 | * @param bool $noSimbol |
||
| 587 | * @return string |
||
| 588 | */ |
||
| 589 | public function getSmartyConditions($condition = '', $operator = '', $type = '', $contentIf = '', $contentElse = false, $count = false, $noSimbol = false) |
||
| 617 | |||
| 618 | /** |
||
| 619 | * @public function getSmartyForeach |
||
| 620 | * @param string $item |
||
| 621 | * @param string $from |
||
| 622 | * @param string $content |
||
| 623 | * |
||
| 624 | * @param string $name |
||
| 625 | * @param string $key |
||
| 626 | * @return string |
||
| 627 | */ |
||
| 628 | public function getSmartyForeach($item = 'item', $from = 'from', $content = 'content', $name = '', $key = '') |
||
| 638 | |||
| 639 | /** |
||
| 640 | * @public function getSmartyForeachQuery |
||
| 641 | * @param string $item |
||
| 642 | * @param string $from |
||
| 643 | * @param string $content |
||
| 644 | * |
||
| 645 | * @param string $loop |
||
| 646 | * @param string $key |
||
| 647 | * @return string |
||
| 648 | */ |
||
| 649 | public function getSmartyForeachQuery($item = 'item', $from = 'from', $content = 'content', $loop = 'loop', $key = '') |
||
| 659 | |||
| 660 | /** |
||
| 661 | * @public function getSmartySection |
||
| 662 | * @param string $name |
||
| 663 | * @param string $loop |
||
| 664 | * @param string $content |
||
| 665 | * |
||
| 666 | * @param int $start |
||
| 667 | * @param int $step |
||
| 668 | * @return string |
||
| 669 | */ |
||
| 670 | public function getSmartySection($name = 'name', $loop = 'loop', $content = 'content', $start = 0, $step = 0) |
||
| 671 | { |
||
| 672 | $start = 0 != $start ? " start={$start}" : ''; |
||
| 673 | $step = 0 != $step ? " step={$step}" : ''; |
||
| 674 | $ret = "<{section name={$name} loop=\${$loop}{$start}{$step}}>\n"; |
||
| 675 | $ret .= "\t{$content}\n"; |
||
| 676 | $ret .= "<{/section}>\n"; |
||
| 677 | |||
| 678 | return $ret; |
||
| 679 | } |
||
| 681 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.