Kylob/Pagination

View on GitHub
src/Component.php

Summary

Maintainability
D
2 days
Test Coverage

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

    public function pager($previous = 'Previous', $next = 'Next')
    {
        $links = '';
        if (!empty($previous)) {
            if (is_array($previous)) {
Severity: Minor
Found in src/Component.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

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

    public function links($pad = 3)
    {
        if ($this->get === false || $this->total === 1) {
            return '';
        }
Severity: Minor
Found in src/Component.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 html has 61 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function html($type = 'bootstrap', array $options = array())
    {
        if ($type == 'links' && !empty($this->links)) {
            $this->links = array_merge($this->links, $options);
        } elseif ($type == 'pager' && !empty($this->pager)) {
Severity: Major
Found in src/Component.php - About 2 hrs to fix

    File Component.php has 267 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace BootPress\Pagination;
    
    use BootPress\Page\Component as Page;
    Severity: Minor
    Found in src/Component.php - About 2 hrs to fix

      Method links has 48 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function links($pad = 3)
          {
              if ($this->get === false || $this->total === 1) {
                  return '';
              }
      Severity: Minor
      Found in src/Component.php - About 1 hr to fix

        Function __get has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            public function __get($name)
            {
                switch ($name) {
                    case 'pager':
                    case 'links':
        Severity: Minor
        Found in src/Component.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 __get has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function __get($name)
            {
                switch ($name) {
                    case 'pager':
                    case 'links':
        Severity: Minor
        Found in src/Component.php - About 1 hr to fix

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

              public function html($type = 'bootstrap', array $options = array())
              {
                  if ($type == 'links' && !empty($this->links)) {
                      $this->links = array_merge($this->links, $options);
                  } elseif ($type == 'pager' && !empty($this->pager)) {
          Severity: Minor
          Found in src/Component.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 set has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              public function set($page = 'page', $limit = 10, $url = null)
              {
                  if (is_null($url)) {
                      $url = $this->page->url();
                  }
          Severity: Minor
          Found in src/Component.php - About 45 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;
          Severity: Major
          Found in src/Component.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                            return ($this->get && $this->current < $this->total) ? $this->page($this->current + 1) : null;
            Severity: Major
            Found in src/Component.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                              return ($this->get && $this->current > 1) ? $this->page($this->current - 1) : null;
              Severity: Major
              Found in src/Component.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                return ($this->get && $this->current == $this->total) ? true : false;
                Severity: Major
                Found in src/Component.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                  return ($this->get) ? $this->current : 1;
                  Severity: Major
                  Found in src/Component.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                    return ($this->get) ? $this->total : 1;
                    Severity: Major
                    Found in src/Component.php - About 30 mins to fix

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

                          private function format($string, $value, $url = null)
                          {
                              if (is_string($string)) {
                                  if (is_null($url) && is_numeric($value)) {
                                      $url = $value;
                      Severity: Minor
                      Found in src/Component.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