Kylob/BootPress

View on GitHub
src/Analytics/Component.php

Summary

Maintainability
F
5 days
Test Coverage

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

<?php

namespace BootPress\Analytics;

use BootPress\Page\Component as Page;
Severity: Major
Found in src/Analytics/Component.php - About 1 day to fix

    Method log has 146 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function log()
        {
            // Get initial values
            $page = Page::html();
            $log = array(); // csv lines
    Severity: Major
    Found in src/Analytics/Component.php - About 5 hrs to fix

      Function log has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function log()
          {
              // Get initial values
              $page = Page::html();
              $log = array(); // csv lines
      Severity: Minor
      Found in src/Analytics/Component.php - About 5 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 location has 106 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function location($timezone, $hemisphere = '')
          {
              static $timezones = array(
                  'UM12' => 'Baker / Howland Islands',
                  'UM11' => array(
      Severity: Major
      Found in src/Analytics/Component.php - About 4 hrs to fix

        Method process has 94 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function process()
            {
                $page = Page::html();
                $file = $page->file('analytics.csv');
                $temp = $page->file('analytics-temp.csv');
        Severity: Major
        Found in src/Analytics/Component.php - About 3 hrs to fix

          Function exec has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
          Open

              private static function exec($action, $table, $values = null)
              {
                  $action = strtolower($action);
                  if (!isset(self::$stmt[$action][$table])) {
                      switch ($action) {
          Severity: Minor
          Found in src/Analytics/Component.php - About 3 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 process has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function process()
              {
                  $page = Page::html();
                  $file = $page->file('analytics.csv');
                  $temp = $page->file('analytics-temp.csv');
          Severity: Minor
          Found in src/Analytics/Component.php - About 3 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 database has 69 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function database()
              {
                  $page = Page::html();
                  $db = new SQLite($page->file('Analytics.db'));
                  if ($db->created || version_compare(self::VERSION, $db->settings('version'), '>')) {
          Severity: Major
          Found in src/Analytics/Component.php - About 2 hrs to fix

            Method exec has 67 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private static function exec($action, $table, $values = null)
                {
                    $action = strtolower($action);
                    if (!isset(self::$stmt[$action][$table])) {
                        switch ($action) {
            Severity: Major
            Found in src/Analytics/Component.php - About 2 hrs to fix

              Function id has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                  private static function id($table, $value, array $insert = array())
                  {
                      settype($value, 'string');
                      if (isset(self::$ids[$table][$value])) {
                          return self::$ids[$table][$value];
              Severity: Minor
              Found in src/Analytics/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 id has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private static function id($table, $value, array $insert = array())
                  {
                      settype($value, 'string');
                      if (isset(self::$ids[$table][$value])) {
                          return self::$ids[$table][$value];
              Severity: Minor
              Found in src/Analytics/Component.php - About 1 hr to fix

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

                    private static function sessionCookie()
                    {
                        $page = Page::html();
                        $now = microtime(true);
                        $time = floor($now);
                Severity: Minor
                Found in src/Analytics/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

                Blank line found at start of control structure
                Open

                        } elseif (in_array($page->url['format'], array('html', 'pdf', 'txt', 'xml', 'rdf', 'rss', 'atom'))) {
                Severity: Minor
                Found in src/Analytics/Component.php by phpcodesniffer

                Blank line found at start of control structure
                Open

                        if ($page->request->isXmlHttpRequest()) {
                Severity: Minor
                Found in src/Analytics/Component.php by phpcodesniffer

                Expected 0 spaces after opening bracket; newline found
                Open

                                if (
                Severity: Minor
                Found in src/Analytics/Component.php by phpcodesniffer

                There are no issues that match your filters.

                Category
                Status