src/Twig/Theme.php

Summary

Maintainability
F
3 days
Test Coverage

Method getTwig has 239 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getTwig(array $options = array())
    {
        if (is_null($this->twig)) {
            $page = Page::html();
            foreach (array('content', 'plugins', 'themes') as $dir) {
Severity: Major
Found in src/Twig/Theme.php - About 1 day to fix

    File Theme.php has 509 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace BootPress\Blog\Twig;
    
    use BootPress\Page\Component as Page;
    Severity: Major
    Found in src/Twig/Theme.php - About 1 day to fix

      Function getFiles has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

          private function getFiles($name, $default = null)
          {
              $files = array();
              if (!empty($name)) {
                  $page = Page::html();
      Severity: Minor
      Found in src/Twig/Theme.php - About 2 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method renderTwig has 52 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function renderTwig($file, array $vars = array())
          {
              $page = Page::html();
              if (is_array($file)) {
                  $vars = (isset($file['vars']) && is_array($file['vars'])) ? $file['vars'] : array();
      Severity: Major
      Found in src/Twig/Theme.php - About 2 hrs to fix

        Function renderTwig has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            public function renderTwig($file, array $vars = array())
            {
                $page = Page::html();
                if (is_array($file)) {
                    $vars = (isset($file['vars']) && is_array($file['vars'])) ? $file['vars'] : array();
        Severity: Minor
        Found in src/Twig/Theme.php - About 1 hr to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Method getFiles has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function getFiles($name, $default = null)
            {
                $files = array();
                if (!empty($name)) {
                    $page = Page::html();
        Severity: Minor
        Found in src/Twig/Theme.php - About 1 hr to fix

          Function this has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              public function this(\Twig_Template $twig, $key = null, $value = null)
              {
                  $name = $twig->getTemplateName();
                  if (!isset($this->plugin[$name])) {
                      $this->plugin[$name] = array();
          Severity: Minor
          Found in src/Twig/Theme.php - About 55 mins to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Function wringer has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              private static function wringer($data)
              {
                  if (is_object($data)) {
                      if ($data instanceof \BootPress\Blog\Twig\Object) {
                          $data = $data->properties + $data->methods;
          Severity: Minor
          Found in src/Twig/Theme.php - About 55 mins to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Function asset has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public function asset($path, \Twig_Template $twig = null)
              {
                  if (is_string($path)) {
                      if ($this->asset && preg_match('/^'.implode('', array(
                          '(?!((f|ht)tps?:)?\/\/)',
          Severity: Minor
          Found in src/Twig/Theme.php - About 35 mins to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Function layout has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public function layout($html)
              {
                  $page = Page::html();
                  $theme = $page->theme;
                  if ($theme === false) {
          Severity: Minor
          Found in src/Twig/Theme.php - About 35 mins to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Avoid too many return statements within this method.
          Open

                  return $this->twig;
          Severity: Major
          Found in src/Twig/Theme.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    return $this->renderTwig(array_pop($index), $vars);
            Severity: Major
            Found in src/Twig/Theme.php - About 30 mins to fix

              Function getTwig has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function getTwig(array $options = array())
                  {
                      if (is_null($this->twig)) {
                          $page = Page::html();
                          foreach (array('content', 'plugins', 'themes') as $dir) {
              Severity: Minor
              Found in src/Twig/Theme.php - About 25 mins to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              There are no issues that match your filters.

              Category
              Status