| Conditions | 62 |
| Paths | > 20000 |
| Total Lines | 412 |
| Code Lines | 199 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 349 | public function render(array $options = []) |
||
| 350 | { |
||
| 351 | if (profiler() !== false) { |
||
| 352 | profiler()->watch('Starting View Rendering'); |
||
| 353 | } |
||
| 354 | |||
| 355 | parser()->loadVars(presenter()->getArrayCopy()); |
||
| 356 | |||
| 357 | if (presenter()->page->file instanceof \SplFileInfo) { |
||
| 358 | |||
| 359 | if (false === ($pagePresets = presenter()->page->getPresets())) { |
||
| 360 | if (presenter()->page->file->getFilename() === 'index') { |
||
| 361 | $title = presenter()->page->file->getDirectoryInfo()->getDirName(); |
||
| 362 | } else { |
||
| 363 | $titles[] = presenter()->page->file->getDirectoryInfo()->getDirName(); |
||
| 364 | $titles[] = presenter()->page->file->getFilename(); |
||
| 365 | |||
| 366 | $title = implode(' - ', array_unique($titles)); |
||
| 367 | } |
||
| 368 | |||
| 369 | $pagePresets = new SplArrayObject([ |
||
| 370 | 'title' => readable($title, true), |
||
| 371 | 'access' => 'public', |
||
| 372 | ]); |
||
| 373 | } |
||
| 374 | |||
| 375 | /** |
||
| 376 | * Sets Page Theme |
||
| 377 | */ |
||
| 378 | if ($pagePresets->offsetExists('theme')) { |
||
| 379 | presenter()->setTheme($pagePresets->theme); |
||
| 380 | } elseif (false !== ($theme = presenter()->getConfig('theme'))) { |
||
| 381 | if (modules()->top()->hasTheme($theme)) { |
||
| 382 | presenter()->setTheme($theme); |
||
| 383 | } |
||
| 384 | } |
||
| 385 | |||
| 386 | /** |
||
| 387 | * Sets Page Layout |
||
| 388 | */ |
||
| 389 | if (presenter()->theme !== false) { |
||
| 390 | if ($pagePresets->offsetExists('layout')) { |
||
| 391 | presenter()->theme->setLayout($pagePresets->layout); |
||
| 392 | } |
||
| 393 | |||
| 394 | /** |
||
| 395 | * Autoload Theme Assets |
||
| 396 | */ |
||
| 397 | presenter()->theme->load(); |
||
| 398 | |||
| 399 | if (false !== ($modulePresets = modules()->top()->getPresets())) { |
||
| 400 | |||
| 401 | /** |
||
| 402 | * Autoload Module Assets |
||
| 403 | */ |
||
| 404 | if ($modulePresets->offsetExists('assets')) { |
||
| 405 | presenter()->assets->autoload($modulePresets->assets); |
||
| 406 | } |
||
| 407 | |||
| 408 | /** |
||
| 409 | * Sets Module Meta |
||
| 410 | */ |
||
| 411 | if ($modulePresets->offsetExists('title')) { |
||
| 412 | presenter()->meta->title->append(language()->getLine($modulePresets->title)); |
||
| 413 | } |
||
| 414 | |||
| 415 | if ($modulePresets->offsetExists('pageTitle')) { |
||
| 416 | presenter()->meta->title->replace(language()->getLine($modulePresets->pageTitle)); |
||
| 417 | } |
||
| 418 | |||
| 419 | if ($modulePresets->offsetExists('browserTitle')) { |
||
| 420 | presenter()->meta->title->replace(language()->getLine($modulePresets->browserTitle)); |
||
| 421 | } |
||
| 422 | |||
| 423 | if ($modulePresets->offsetExists('meta')) { |
||
| 424 | foreach ($modulePresets->meta as $name => $content) { |
||
| 425 | presenter()->meta->store($name, $content); |
||
| 426 | } |
||
| 427 | } |
||
| 428 | } |
||
| 429 | |||
| 430 | $moduleAssets = [ |
||
| 431 | 'app', |
||
| 432 | 'module', |
||
| 433 | modules()->top()->getParameter(), |
||
| 434 | ]; |
||
| 435 | |||
| 436 | // Autoload Assets |
||
| 437 | presenter()->assets->loadCss($moduleAssets); |
||
| 438 | presenter()->assets->loadJs($moduleAssets); |
||
| 439 | |||
| 440 | /** |
||
| 441 | * Autoload Page Assets |
||
| 442 | */ |
||
| 443 | if ($pagePresets->offsetExists('assets')) { |
||
| 444 | presenter()->assets->autoload($pagePresets->assets); |
||
| 445 | } |
||
| 446 | |||
| 447 | if (presenter()->page->file instanceof \SplFileInfo) { |
||
| 448 | $pageDir = presenter()->page->file->getRealPath(); |
||
| 449 | $pageDir = str_replace('.' . pathinfo($pageDir, PATHINFO_EXTENSION), '', $pageDir); |
||
| 450 | $pageDirParts = explode('pages' . DIRECTORY_SEPARATOR, |
||
| 451 | str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $pageDir)); |
||
| 452 | $pageDir = end($pageDirParts); |
||
| 453 | |||
| 454 | $pageDir = rtrim($pageDir, DIRECTORY_SEPARATOR); |
||
| 455 | $pageDirParts = explode(DIRECTORY_SEPARATOR, $pageDir); |
||
| 456 | |||
| 457 | $totalParts = count($pageDirParts); |
||
| 458 | |||
| 459 | for ($i = 0; $i < $totalParts; $i++) { |
||
| 460 | $pageAssets[] = implode(DIRECTORY_SEPARATOR, array_slice($pageDirParts, 0, ($totalParts - $i))); |
||
| 461 | } |
||
| 462 | |||
| 463 | $pageAssets[] = implode(DIRECTORY_SEPARATOR, [end($pageAssets), end($pageAssets)]); |
||
| 464 | |||
| 465 | // Autoload Assets |
||
| 466 | presenter()->assets->loadCss($pageAssets); |
||
| 467 | presenter()->assets->loadJs($pageAssets); |
||
| 468 | } |
||
| 469 | |||
| 470 | /** |
||
| 471 | * Sets Page Meta |
||
| 472 | */ |
||
| 473 | if ($pagePresets->offsetExists('title')) { |
||
| 474 | presenter()->meta->title->append(language()->getLine($pagePresets->title)); |
||
| 475 | } |
||
| 476 | |||
| 477 | if ($pagePresets->offsetExists('pageTitle')) { |
||
| 478 | presenter()->meta->title->replace(language()->getLine($pagePresets->pageTitle)); |
||
| 479 | } |
||
| 480 | |||
| 481 | if ($pagePresets->offsetExists('browserTitle')) { |
||
| 482 | presenter()->meta->title->replace(language()->getLine($pagePresets->browserTitle)); |
||
| 483 | } |
||
| 484 | |||
| 485 | if ($pagePresets->offsetExists('meta')) { |
||
| 486 | foreach ($pagePresets->meta as $name => $content) { |
||
| 487 | presenter()->meta->store($name, $content); |
||
| 488 | } |
||
| 489 | } |
||
| 490 | |||
| 491 | if (false !== ($layout = presenter()->theme->getLayout())) { |
||
| 492 | parser()->loadFile($layout->getRealPath()); |
||
| 493 | |||
| 494 | $htmlOutput = parser()->parse(); |
||
| 495 | $htmlOutput = presenter()->assets->parseSourceCode($htmlOutput); |
||
| 496 | |||
| 497 | $this->document->loadHTML($htmlOutput); |
||
| 498 | } |
||
| 499 | } else { |
||
| 500 | output()->sendError(204, language()->getLine('E_THEME_NOT_FOUND', [$theme])); |
||
| 501 | } |
||
| 502 | } elseif (presenter()->theme instanceof Theme) { |
||
| 503 | /** |
||
| 504 | * Autoload Theme Assets |
||
| 505 | */ |
||
| 506 | presenter()->theme->load(); |
||
| 507 | |||
| 508 | if (false !== ($modulePresets = modules()->top()->getPresets())) { |
||
| 509 | |||
| 510 | /** |
||
| 511 | * Autoload Module Assets |
||
| 512 | */ |
||
| 513 | if ($modulePresets->offsetExists('assets')) { |
||
| 514 | presenter()->assets->autoload($modulePresets->assets); |
||
| 515 | } |
||
| 516 | |||
| 517 | /** |
||
| 518 | * Sets Module Meta |
||
| 519 | */ |
||
| 520 | if ($modulePresets->offsetExists('title')) { |
||
| 521 | presenter()->meta->title->append(language()->getLine($modulePresets->title)); |
||
| 522 | } |
||
| 523 | |||
| 524 | if ($modulePresets->offsetExists('pageTitle')) { |
||
| 525 | presenter()->meta->title->replace(language()->getLine($modulePresets->pageTitle)); |
||
| 526 | } |
||
| 527 | |||
| 528 | if ($modulePresets->offsetExists('browserTitle')) { |
||
| 529 | presenter()->meta->title->replace(language()->getLine($modulePresets->browserTitle)); |
||
| 530 | } |
||
| 531 | |||
| 532 | if ($modulePresets->offsetExists('meta')) { |
||
| 533 | foreach ($modulePresets->meta as $name => $content) { |
||
| 534 | presenter()->meta->store($name, $content); |
||
| 535 | } |
||
| 536 | } |
||
| 537 | } |
||
| 538 | |||
| 539 | $moduleAssets = [ |
||
| 540 | 'app', |
||
| 541 | 'module', |
||
| 542 | modules()->top()->getParameter(), |
||
| 543 | ]; |
||
| 544 | |||
| 545 | // Autoload Assets |
||
| 546 | presenter()->assets->loadCss($moduleAssets); |
||
| 547 | presenter()->assets->loadJs($moduleAssets); |
||
| 548 | |||
| 549 | /** |
||
| 550 | * Autoload Controller Assets |
||
| 551 | */ |
||
| 552 | $controllerFilename = str_replace([modules()->top()->getDir('Controllers'), '.php'], '', |
||
| 553 | controller()->getFileInfo()->getRealPath()); |
||
| 554 | $controllerFilename = dash($controllerFilename); |
||
| 555 | $controllerAssets[] = $controllerFilename; |
||
| 556 | $controllerAssets[] = implode('/', [ |
||
| 557 | $controllerFilename, |
||
| 558 | controller()->getRequestMethod(), |
||
| 559 | ]); |
||
| 560 | |||
| 561 | presenter()->assets->loadCss($controllerAssets); |
||
| 562 | presenter()->assets->loadJs($controllerAssets); |
||
| 563 | |||
| 564 | if (false !== ($layout = presenter()->theme->getLayout())) { |
||
| 565 | parser()->loadFile($layout->getRealPath()); |
||
| 566 | |||
| 567 | $htmlOutput = parser()->parse(); |
||
| 568 | $htmlOutput = presenter()->assets->parseSourceCode($htmlOutput); |
||
| 569 | |||
| 570 | $this->document->loadHTML($htmlOutput); |
||
| 571 | } |
||
| 572 | } elseif (false !== ($theme = presenter()->getConfig('theme'))) { |
||
| 573 | if (modules()->top()->hasTheme($theme)) { |
||
| 574 | presenter()->setTheme($theme); |
||
| 575 | |||
| 576 | /** |
||
| 577 | * Autoload Theme Assets |
||
| 578 | */ |
||
| 579 | presenter()->theme->load(); |
||
| 580 | |||
| 581 | if (false !== ($modulePresets = modules()->top()->getPresets())) { |
||
| 582 | |||
| 583 | /** |
||
| 584 | * Autoload Module Assets |
||
| 585 | */ |
||
| 586 | if ($modulePresets->offsetExists('assets')) { |
||
| 587 | presenter()->assets->autoload($modulePresets->assets); |
||
| 588 | } |
||
| 589 | |||
| 590 | /** |
||
| 591 | * Sets Module Meta |
||
| 592 | */ |
||
| 593 | if ($modulePresets->offsetExists('title')) { |
||
| 594 | presenter()->meta->title->append(language()->getLine($modulePresets->title)); |
||
| 595 | } |
||
| 596 | |||
| 597 | if ($modulePresets->offsetExists('pageTitle')) { |
||
| 598 | presenter()->meta->title->replace(language()->getLine($modulePresets->pageTitle)); |
||
| 599 | } |
||
| 600 | |||
| 601 | if ($modulePresets->offsetExists('browserTitle')) { |
||
| 602 | presenter()->meta->title->replace(language()->getLine($modulePresets->browserTitle)); |
||
| 603 | } |
||
| 604 | |||
| 605 | if ($modulePresets->offsetExists('meta')) { |
||
| 606 | foreach ($modulePresets->meta as $name => $content) { |
||
| 607 | presenter()->meta->store($name, $content); |
||
| 608 | } |
||
| 609 | } |
||
| 610 | } |
||
| 611 | |||
| 612 | $moduleAssets = [ |
||
| 613 | 'app', |
||
| 614 | 'module', |
||
| 615 | modules()->top()->getParameter(), |
||
| 616 | ]; |
||
| 617 | |||
| 618 | // Autoload Assets |
||
| 619 | presenter()->assets->loadCss($moduleAssets); |
||
| 620 | presenter()->assets->loadJs($moduleAssets); |
||
| 621 | |||
| 622 | /** |
||
| 623 | * Autoload Controller Assets |
||
| 624 | */ |
||
| 625 | $controllerFilename = str_replace([modules()->top()->getDir('Controllers'), '.php'], '', |
||
| 626 | controller()->getFileInfo()->getRealPath()); |
||
| 627 | $controllerFilename = dash($controllerFilename); |
||
| 628 | $controllerAssets[] = $controllerFilename; |
||
| 629 | $controllerAssets[] = implode('/', [ |
||
| 630 | $controllerFilename, |
||
| 631 | controller()->getRequestMethod(), |
||
| 632 | ]); |
||
| 633 | |||
| 634 | if (false !== ($layout = presenter()->theme->getLayout())) { |
||
| 635 | parser()->loadFile($layout->getRealPath()); |
||
| 636 | |||
| 637 | $htmlOutput = parser()->parse(); |
||
| 638 | $htmlOutput = presenter()->assets->parseSourceCode($htmlOutput); |
||
| 639 | |||
| 640 | $this->document->loadHTML($htmlOutput); |
||
| 641 | } |
||
| 642 | } else { |
||
| 643 | output()->sendError(204, language()->getLine('E_THEME_NOT_FOUND', [$theme])); |
||
| 644 | } |
||
| 645 | } else { |
||
| 646 | $this->document->find('body')->append(presenter()->partials->__get('content')); |
||
| 647 | } |
||
| 648 | |||
| 649 | /** |
||
| 650 | * Set Document Meta Title |
||
| 651 | */ |
||
| 652 | if (presenter()->meta->title instanceof Meta\Title) { |
||
| 653 | $this->document->title->text(presenter()->meta->title->__toString()); |
||
| 654 | } |
||
| 655 | |||
| 656 | /** |
||
| 657 | * Injecting Meta Opengraph |
||
| 658 | */ |
||
| 659 | if (presenter()->meta->opengraph instanceof Meta\Opengraph) { |
||
| 660 | // set opengraph title |
||
| 661 | if (presenter()->meta->title instanceof Meta\Title) { |
||
| 662 | presenter()->meta->opengraph->setTitle(presenter()->meta->title->__toString()); |
||
| 663 | } |
||
| 664 | |||
| 665 | // set opengraph site name |
||
| 666 | if (presenter()->exists('siteName')) { |
||
| 667 | presenter()->meta->opengraph->setSiteName(presenter()->offsetGet('siteName')); |
||
| 668 | } |
||
| 669 | |||
| 670 | if (presenter()->meta->opengraph->count()) { |
||
| 671 | $htmlElement = $this->document->getElementsByTagName('html')->item(0); |
||
| 672 | $htmlElement->setAttribute('prefix', 'og: ' . presenter()->meta->opengraph->prefix); |
||
| 673 | |||
| 674 | if (presenter()->meta->opengraph->exists('og:type') === false) { |
||
| 675 | presenter()->meta->opengraph->setType('website'); |
||
| 676 | } |
||
| 677 | |||
| 678 | $opengraph = presenter()->meta->opengraph->getArrayCopy(); |
||
| 679 | |||
| 680 | foreach ($opengraph as $tag) { |
||
| 681 | $this->document->metaNodes->createElement($tag->attributes->getArrayCopy()); |
||
| 682 | } |
||
| 683 | } |
||
| 684 | } |
||
| 685 | |||
| 686 | if (presenter()->meta->count()) { |
||
| 687 | $meta = presenter()->meta->getArrayCopy(); |
||
| 688 | |||
| 689 | foreach ($meta as $tag) { |
||
| 690 | $this->document->metaNodes->createElement($tag->attributes->getArrayCopy()); |
||
| 691 | } |
||
| 692 | } |
||
| 693 | |||
| 694 | /** |
||
| 695 | * Inject body attributes |
||
| 696 | */ |
||
| 697 | $body = $this->document->getElementsByTagName('body'); |
||
| 698 | $body->item(0)->setAttribute('module', modules()->top()->getParameter()); |
||
| 699 | |||
| 700 | /** |
||
| 701 | * Injecting Single Sign-On (SSO) iFrame |
||
| 702 | */ |
||
| 703 | if (services()->has('user')) { |
||
| 704 | $iframe = services()->get('user')->getIframeCode(); |
||
| 705 | |||
| 706 | if ( ! empty($iframe)) { |
||
| 707 | $this->document->find('body')->append($iframe); |
||
| 708 | } |
||
| 709 | } |
||
| 710 | |||
| 711 | if (input()->env('DEBUG_STAGE') === 'DEVELOPER' and |
||
| 712 | presenter()->getConfig('debugToolBar') === true and |
||
| 713 | services()->has('profiler') |
||
| 714 | ) { |
||
| 715 | $this->document->find('body')->append((new Toolbar())->__toString()); |
||
| 716 | } |
||
| 717 | |||
| 718 | /** |
||
| 719 | * Injecting Progressive Web Application (PWA) Manifest |
||
| 720 | */ |
||
| 721 | $this->document->linkNodes->createElement([ |
||
| 722 | 'rel' => 'manifest', |
||
| 723 | 'href' => '/manifest.json', |
||
| 724 | ]); |
||
| 725 | |||
| 726 | $htmlOutput = $this->document->saveHTML(); |
||
| 727 | |||
| 728 | // Uglify Output |
||
| 729 | if ($this->config->output[ 'uglify' ] === true) { |
||
| 730 | $htmlOutput = preg_replace( |
||
| 731 | [ |
||
| 732 | '/\>[^\S ]+/s', // strip whitespaces after tags, except space |
||
| 733 | '/[^\S ]+\</s', // strip whitespaces before tags, except space |
||
| 734 | '/(\s)+/s', // shorten multiple whitespace sequences |
||
| 735 | '/<!--(.|\s)*?-->/', // Remove HTML comments |
||
| 736 | '/<!--(.*)-->/Uis', |
||
| 737 | "/[[:blank:]]+/", |
||
| 738 | ], |
||
| 739 | [ |
||
| 740 | '>', |
||
| 741 | '<', |
||
| 742 | '\\1', |
||
| 743 | '', |
||
| 744 | '', |
||
| 745 | ' ', |
||
| 746 | ], |
||
| 747 | str_replace(["\n", "\r", "\t"], '', $htmlOutput)); |
||
| 748 | } |
||
| 749 | |||
| 750 | // Beautify Output |
||
| 751 | if ($this->config->output[ 'beautify' ] === true) { |
||
| 752 | $beautifier = new Html\Dom\Beautifier(); |
||
| 753 | $htmlOutput = $beautifier->format($htmlOutput); |
||
| 754 | } |
||
| 755 | |||
| 756 | if (profiler() !== false) { |
||
| 757 | profiler()->watch('Ending View Rendering'); |
||
| 758 | } |
||
| 759 | |||
| 760 | return $htmlOutput; |
||
| 761 | } |
||
| 763 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.