ampache/ampache

View on GitHub
src/Module/Statistics/Stats.php

Summary

Maintainability
F
5 days
Test Coverage

File Stats.php has 739 lines of code (exceeds 500 allowed). Consider refactoring.
Open

<?php

declare(strict_types=0);

/**
Severity: Major
Found in src/Module/Statistics/Stats.php - About 7 hrs to fix

    Function get_top_sql has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function get_top_sql(
            $input_type,
            $threshold,
            $count_type = 'stream',
            $user_id = null,
    Severity: Minor
    Found in src/Module/Statistics/Stats.php - About 6 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

    Stats has 31 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Stats
    {
        /* Base vars */
        public int $id = 0;
        public ?string $object_type;
    Severity: Minor
    Found in src/Module/Statistics/Stats.php - About 3 hrs to fix

      The class Stats has an overall complexity of 227 which is very high. The configured complexity threshold is 50.
      Open

      class Stats
      {
          /* Base vars */
          public int $id = 0;
          public ?string $object_type;
      Severity: Minor
      Found in src/Module/Statistics/Stats.php by phpmd

      The class Stats has 11 public methods. Consider refactoring Stats to keep number of public methods under 10.
      Open

      class Stats
      {
          /* Base vars */
          public int $id = 0;
          public ?string $object_type;
      Severity: Minor
      Found in src/Module/Statistics/Stats.php by phpmd

      TooManyPublicMethods

      Since: 0.1

      A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

      By default it ignores methods starting with 'get' or 'set'.

      Example

      Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

      Function get_newest_sql has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function get_newest_sql($input_type, $catalog_id = 0, $user_id = null): string
          {
              $type = self::validate_type($input_type);
              // all objects could be filtered
              $catalog_filter = (AmpConfig::get('catalog_filter'));
      Severity: Minor
      Found in src/Module/Statistics/Stats.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

      Function get_recent_sql has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function get_recent_sql($input_type, $user_id = null, $newest = true): string
          {
              $type           = self::validate_type($input_type);
              $ordersql       = ($newest === true) ? 'DESC' : 'ASC';
              $user_sql       = (!empty($user_id)) ? " AND `user` = '" . $user_id . "'" : '';
      Severity: Minor
      Found in src/Module/Statistics/Stats.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

      Function insert has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function insert(
              $input_type,
              $object_id,
              $user_id,
              $agent = '',
      Severity: Minor
      Found in src/Module/Statistics/Stats.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

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

          public static function skip_last_play($date, $agent, $user_id, $object_id, $object_type)
          {
              // change from a stream to a skip
              $sql = "UPDATE `object_count` SET `count_type` = 'skip' WHERE `date` = ? AND `agent` = ? AND `user` = ? AND `object_count`.`object_type` = ? ORDER BY `object_count`.`date` DESC";
              Dba::write($sql, array($date, $agent, $user_id, $object_type));
      Severity: Minor
      Found in src/Module/Statistics/Stats.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

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

          public static function has_played_history($object_type, $object, $user_id, $agent, $date): bool
          {
              if (AmpConfig::get('use_auth') && $user_id == -1) {
                  return false;
              }
      Severity: Minor
      Found in src/Module/Statistics/Stats.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

      Function delete has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function delete(int $activity_id): void
          {
              if ($activity_id > 0) {
                  $sql        = "SELECT `object_count`.`object_id`, `object_count`.`object_type`, `object_count`.`date`, `object_count`.`user`, `object_count`.`agent`, `object_count`.`count_type` FROM `object_count` WHERE `object_count`.`id` = ?;";
                  $db_results = Dba::read($sql, array($activity_id));
      Severity: Minor
      Found in src/Module/Statistics/Stats.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_top_sql has 8 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              $input_type,
              $threshold,
              $count_type = 'stream',
              $user_id = null,
              $random = false,
      Severity: Major
      Found in src/Module/Statistics/Stats.php - About 1 hr to fix

        Method get_top has 8 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            public static function get_top($input_type, $count, $threshold, $offset = 0, $user_id = null, $random = false, $since = 0, $before = 0): array
        Severity: Major
        Found in src/Module/Statistics/Stats.php - About 1 hr to fix

          Method insert has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  $input_type,
                  $object_id,
                  $user_id,
                  $agent = '',
                  $location = [],
          Severity: Major
          Found in src/Module/Statistics/Stats.php - About 50 mins to fix

            Method is_already_inserted has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                public static function is_already_inserted($type, $object_id, $user, $agent, $time, $exact = false): bool
            Severity: Minor
            Found in src/Module/Statistics/Stats.php - About 45 mins to fix

              Method skip_last_play has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  public static function skip_last_play($date, $agent, $user_id, $object_id, $object_type)
              Severity: Minor
              Found in src/Module/Statistics/Stats.php - About 35 mins to fix

                Method get_newest has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    public static function get_newest($input_type, $count = 0, $offset = 0, $catalog_id = 0, $user_id = null): array
                Severity: Minor
                Found in src/Module/Statistics/Stats.php - About 35 mins to fix

                  Method has_played_history has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      public static function has_played_history($object_type, $object, $user_id, $agent, $date): bool
                  Severity: Minor
                  Found in src/Module/Statistics/Stats.php - About 35 mins to fix

                    Avoid too many return statements within this method.
                    Open

                            return true;
                    Severity: Major
                    Found in src/Module/Statistics/Stats.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                  return false;
                      Severity: Major
                      Found in src/Module/Statistics/Stats.php - About 30 mins to fix

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

                            public static function get_recently_played($user_id, $count_type = 'stream', $object_type = null, $user_only = false): array
                            {
                                $personal_info_recent = 91;
                                $personal_info_time   = 92;
                                $personal_info_agent  = 93;
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.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

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

                            public static function get_object_count($object_type, $object_id, $threshold = null, $count_type = 'stream'): int
                            {
                                if ($threshold === null || $threshold === '') {
                                    $threshold = 0;
                                }
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.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

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

                            public static function get_object_total($object_type, $object_id, $threshold = null, $count_type = 'stream'): int
                            {
                                if ($threshold === null || $threshold === '') {
                                    $threshold = 0;
                                }
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.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

                        The method insert() has an NPath complexity of 1344. The configured NPath complexity threshold is 200.
                        Open

                            public static function insert(
                                $input_type,
                                $object_id,
                                $user_id,
                                $agent = '',
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        NPathComplexity

                        Since: 0.1

                        The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                        Example

                        class Foo {
                            function bar() {
                                // lots of complicated code
                            }
                        }

                        Source https://phpmd.org/rules/codesize.html#npathcomplexity

                        The class Stats has 1095 lines of code. Current threshold is 1000. Avoid really long classes.
                        Open

                        class Stats
                        {
                            /* Base vars */
                            public int $id = 0;
                            public ?string $object_type;
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        The method get_top_sql() has an NPath complexity of 16589600. The configured NPath complexity threshold is 200.
                        Open

                            public static function get_top_sql(
                                $input_type,
                                $threshold,
                                $count_type = 'stream',
                                $user_id = null,
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        NPathComplexity

                        Since: 0.1

                        The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                        Example

                        class Foo {
                            function bar() {
                                // lots of complicated code
                            }
                        }

                        Source https://phpmd.org/rules/codesize.html#npathcomplexity

                        The method get_newest_sql() has an NPath complexity of 2304. The configured NPath complexity threshold is 200.
                        Open

                            public static function get_newest_sql($input_type, $catalog_id = 0, $user_id = null): string
                            {
                                $type = self::validate_type($input_type);
                                // all objects could be filtered
                                $catalog_filter = (AmpConfig::get('catalog_filter'));
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        NPathComplexity

                        Since: 0.1

                        The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                        Example

                        class Foo {
                            function bar() {
                                // lots of complicated code
                            }
                        }

                        Source https://phpmd.org/rules/codesize.html#npathcomplexity

                        The method has_played_history() has an NPath complexity of 648. The configured NPath complexity threshold is 200.
                        Open

                            public static function has_played_history($object_type, $object, $user_id, $agent, $date): bool
                            {
                                if (AmpConfig::get('use_auth') && $user_id == -1) {
                                    return false;
                                }
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        NPathComplexity

                        Since: 0.1

                        The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                        Example

                        class Foo {
                            function bar() {
                                // lots of complicated code
                            }
                        }

                        Source https://phpmd.org/rules/codesize.html#npathcomplexity

                        The method get_top_sql() has 104 lines of code. Current threshold is set to 100. Avoid really long methods.
                        Open

                            public static function get_top_sql(
                                $input_type,
                                $threshold,
                                $count_type = 'stream',
                                $user_id = null,
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        The method get_recent_sql() has an NPath complexity of 6144. The configured NPath complexity threshold is 200.
                        Open

                            public static function get_recent_sql($input_type, $user_id = null, $newest = true): string
                            {
                                $type           = self::validate_type($input_type);
                                $ordersql       = ($newest === true) ? 'DESC' : 'ASC';
                                $user_sql       = (!empty($user_id)) ? " AND `user` = '" . $user_id . "'" : '';
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        NPathComplexity

                        Since: 0.1

                        The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                        Example

                        class Foo {
                            function bar() {
                                // lots of complicated code
                            }
                        }

                        Source https://phpmd.org/rules/codesize.html#npathcomplexity

                        The method get_newest_sql() has a Cyclomatic Complexity of 20. The configured cyclomatic complexity threshold is 10.
                        Open

                            public static function get_newest_sql($input_type, $catalog_id = 0, $user_id = null): string
                            {
                                $type = self::validate_type($input_type);
                                // all objects could be filtered
                                $catalog_filter = (AmpConfig::get('catalog_filter'));
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CyclomaticComplexity

                        Since: 0.1

                        Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                        Example

                        // Cyclomatic Complexity = 11
                        class Foo {
                        1   public function example() {
                        2       if ($a == $b) {
                        3           if ($a1 == $b1) {
                                        fiddle();
                        4           } elseif ($a2 == $b2) {
                                        fiddle();
                                    } else {
                                        fiddle();
                                    }
                        5       } elseif ($c == $d) {
                        6           while ($c == $d) {
                                        fiddle();
                                    }
                        7        } elseif ($e == $f) {
                        8           for ($n = 0; $n < $h; $n++) {
                                        fiddle();
                                    }
                                } else {
                                    switch ($z) {
                        9               case 1:
                                            fiddle();
                                            break;
                        10              case 2:
                                            fiddle();
                                            break;
                        11              case 3:
                                            fiddle();
                                            break;
                                        default:
                                            fiddle();
                                            break;
                                    }
                                }
                            }
                        }

                        Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                        The method insert() has a Cyclomatic Complexity of 15. The configured cyclomatic complexity threshold is 10.
                        Open

                            public static function insert(
                                $input_type,
                                $object_id,
                                $user_id,
                                $agent = '',
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CyclomaticComplexity

                        Since: 0.1

                        Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                        Example

                        // Cyclomatic Complexity = 11
                        class Foo {
                        1   public function example() {
                        2       if ($a == $b) {
                        3           if ($a1 == $b1) {
                                        fiddle();
                        4           } elseif ($a2 == $b2) {
                                        fiddle();
                                    } else {
                                        fiddle();
                                    }
                        5       } elseif ($c == $d) {
                        6           while ($c == $d) {
                                        fiddle();
                                    }
                        7        } elseif ($e == $f) {
                        8           for ($n = 0; $n < $h; $n++) {
                                        fiddle();
                                    }
                                } else {
                                    switch ($z) {
                        9               case 1:
                                            fiddle();
                                            break;
                        10              case 2:
                                            fiddle();
                                            break;
                        11              case 3:
                                            fiddle();
                                            break;
                                        default:
                                            fiddle();
                                            break;
                                    }
                                }
                            }
                        }

                        Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                        The method count() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10.
                        Open

                            public static function count(string $type, int $object_id, string $count_type): void
                            {
                                switch ($type) {
                                    case 'song':
                                    case 'podcast':
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CyclomaticComplexity

                        Since: 0.1

                        Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                        Example

                        // Cyclomatic Complexity = 11
                        class Foo {
                        1   public function example() {
                        2       if ($a == $b) {
                        3           if ($a1 == $b1) {
                                        fiddle();
                        4           } elseif ($a2 == $b2) {
                                        fiddle();
                                    } else {
                                        fiddle();
                                    }
                        5       } elseif ($c == $d) {
                        6           while ($c == $d) {
                                        fiddle();
                                    }
                        7        } elseif ($e == $f) {
                        8           for ($n = 0; $n < $h; $n++) {
                                        fiddle();
                                    }
                                } else {
                                    switch ($z) {
                        9               case 1:
                                            fiddle();
                                            break;
                        10              case 2:
                                            fiddle();
                                            break;
                        11              case 3:
                                            fiddle();
                                            break;
                                        default:
                                            fiddle();
                                            break;
                                    }
                                }
                            }
                        }

                        Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                        The method has_played_history() has a Cyclomatic Complexity of 13. The configured cyclomatic complexity threshold is 10.
                        Open

                            public static function has_played_history($object_type, $object, $user_id, $agent, $date): bool
                            {
                                if (AmpConfig::get('use_auth') && $user_id == -1) {
                                    return false;
                                }
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CyclomaticComplexity

                        Since: 0.1

                        Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                        Example

                        // Cyclomatic Complexity = 11
                        class Foo {
                        1   public function example() {
                        2       if ($a == $b) {
                        3           if ($a1 == $b1) {
                                        fiddle();
                        4           } elseif ($a2 == $b2) {
                                        fiddle();
                                    } else {
                                        fiddle();
                                    }
                        5       } elseif ($c == $d) {
                        6           while ($c == $d) {
                                        fiddle();
                                    }
                        7        } elseif ($e == $f) {
                        8           for ($n = 0; $n < $h; $n++) {
                                        fiddle();
                                    }
                                } else {
                                    switch ($z) {
                        9               case 1:
                                            fiddle();
                                            break;
                        10              case 2:
                                            fiddle();
                                            break;
                        11              case 3:
                                            fiddle();
                                            break;
                                        default:
                                            fiddle();
                                            break;
                                    }
                                }
                            }
                        }

                        Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                        The method validate_type() has a Cyclomatic Complexity of 18. The configured cyclomatic complexity threshold is 10.
                        Open

                            public static function validate_type($type): string
                            {
                                switch ($type) {
                                    case 'artist':
                                    case 'album':
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CyclomaticComplexity

                        Since: 0.1

                        Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                        Example

                        // Cyclomatic Complexity = 11
                        class Foo {
                        1   public function example() {
                        2       if ($a == $b) {
                        3           if ($a1 == $b1) {
                                        fiddle();
                        4           } elseif ($a2 == $b2) {
                                        fiddle();
                                    } else {
                                        fiddle();
                                    }
                        5       } elseif ($c == $d) {
                        6           while ($c == $d) {
                                        fiddle();
                                    }
                        7        } elseif ($e == $f) {
                        8           for ($n = 0; $n < $h; $n++) {
                                        fiddle();
                                    }
                                } else {
                                    switch ($z) {
                        9               case 1:
                                            fiddle();
                                            break;
                        10              case 2:
                                            fiddle();
                                            break;
                        11              case 3:
                                            fiddle();
                                            break;
                                        default:
                                            fiddle();
                                            break;
                                    }
                                }
                            }
                        }

                        Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                        The method get_recent_sql() has a Cyclomatic Complexity of 17. The configured cyclomatic complexity threshold is 10.
                        Open

                            public static function get_recent_sql($input_type, $user_id = null, $newest = true): string
                            {
                                $type           = self::validate_type($input_type);
                                $ordersql       = ($newest === true) ? 'DESC' : 'ASC';
                                $user_sql       = (!empty($user_id)) ? " AND `user` = '" . $user_id . "'" : '';
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CyclomaticComplexity

                        Since: 0.1

                        Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                        Example

                        // Cyclomatic Complexity = 11
                        class Foo {
                        1   public function example() {
                        2       if ($a == $b) {
                        3           if ($a1 == $b1) {
                                        fiddle();
                        4           } elseif ($a2 == $b2) {
                                        fiddle();
                                    } else {
                                        fiddle();
                                    }
                        5       } elseif ($c == $d) {
                        6           while ($c == $d) {
                                        fiddle();
                                    }
                        7        } elseif ($e == $f) {
                        8           for ($n = 0; $n < $h; $n++) {
                                        fiddle();
                                    }
                                } else {
                                    switch ($z) {
                        9               case 1:
                                            fiddle();
                                            break;
                        10              case 2:
                                            fiddle();
                                            break;
                        11              case 3:
                                            fiddle();
                                            break;
                                        default:
                                            fiddle();
                                            break;
                                    }
                                }
                            }
                        }

                        Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                        The method get_top_sql() has a Cyclomatic Complexity of 36. The configured cyclomatic complexity threshold is 10.
                        Open

                            public static function get_top_sql(
                                $input_type,
                                $threshold,
                                $count_type = 'stream',
                                $user_id = null,
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CyclomaticComplexity

                        Since: 0.1

                        Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                        Example

                        // Cyclomatic Complexity = 11
                        class Foo {
                        1   public function example() {
                        2       if ($a == $b) {
                        3           if ($a1 == $b1) {
                                        fiddle();
                        4           } elseif ($a2 == $b2) {
                                        fiddle();
                                    } else {
                                        fiddle();
                                    }
                        5       } elseif ($c == $d) {
                        6           while ($c == $d) {
                                        fiddle();
                                    }
                        7        } elseif ($e == $f) {
                        8           for ($n = 0; $n < $h; $n++) {
                                        fiddle();
                                    }
                                } else {
                                    switch ($z) {
                        9               case 1:
                                            fiddle();
                                            break;
                        10              case 2:
                                            fiddle();
                                            break;
                        11              case 3:
                                            fiddle();
                                            break;
                                        default:
                                            fiddle();
                                            break;
                                    }
                                }
                            }
                        }

                        Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                        The method get_top_sql uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                        Open

                                } else {
                                    $is_podcast = ($type == 'podcast');
                                    $select_sql = ($is_podcast)
                                        ? "`podcast_episode`.`podcast`"
                                        : "MIN(`object_id`)";
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        ElseExpression

                        Since: 1.4.0

                        An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                        Example

                        class Foo
                        {
                            public function bar($flag)
                            {
                                if ($flag) {
                                    // one branch
                                } else {
                                    // another branch
                                }
                            }
                        }

                        Source https://phpmd.org/rules/cleancode.html#elseexpression

                        The method get_top_sql uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                        Open

                                } else {
                                    $sql .= " ORDER BY `count` DESC ";
                                }
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        ElseExpression

                        Since: 1.4.0

                        An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                        Example

                        class Foo
                        {
                            public function bar($flag)
                            {
                                if ($flag) {
                                    // one branch
                                } else {
                                    // another branch
                                }
                            }
                        }

                        Source https://phpmd.org/rules/cleancode.html#elseexpression

                        The method get_newest_sql uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                        Open

                                } else {
                                    // what else?
                                    $sql      = "SELECT MIN(`$type`) AS `id`, MIN(`song`.`addition_time`) AS `real_atime` FROM `$base_type` ";
                                    $sql_type = "`song`.`" . $type . "`";
                                }
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        ElseExpression

                        Since: 1.4.0

                        An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                        Example

                        class Foo
                        {
                            public function bar($flag)
                            {
                                if ($flag) {
                                    // one branch
                                } else {
                                    // another branch
                                }
                            }
                        }

                        Source https://phpmd.org/rules/cleancode.html#elseexpression

                        The method get_object_count uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                        Open

                                } else {
                                    $sql = "SELECT COUNT(*) AS `total_count` FROM `object_count` WHERE `object_type` = ? AND `object_id` = ? AND `count_type` = ?";
                                    if ($threshold > 0) {
                                        $date = time() - (86400 * (int)$threshold);
                                        $sql .= " AND `date` >= '" . $date . "'";
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        ElseExpression

                        Since: 1.4.0

                        An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                        Example

                        class Foo
                        {
                            public function bar($flag)
                            {
                                if ($flag) {
                                    // one branch
                                } else {
                                    // another branch
                                }
                            }
                        }

                        Source https://phpmd.org/rules/cleancode.html#elseexpression

                        The method clear uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                        Open

                                } else {
                                    Dba::write("TRUNCATE `object_count`;");
                                }
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        ElseExpression

                        Since: 1.4.0

                        An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                        Example

                        class Foo
                        {
                            public function bar($flag)
                            {
                                if ($flag) {
                                    // one branch
                                } else {
                                    // another branch
                                }
                            }
                        }

                        Source https://phpmd.org/rules/cleancode.html#elseexpression

                        The method get_recent_sql uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                        Open

                                } else {
                                    $sql .= " GROUP BY `object_count`.`object_id` ORDER BY MAX(`date`) " . $ordersql . ", `object_count`.`object_id` ";
                                }
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        ElseExpression

                        Since: 1.4.0

                        An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                        Example

                        class Foo
                        {
                            public function bar($flag)
                            {
                                if ($flag) {
                                    // one branch
                                } else {
                                    // another branch
                                }
                            }
                        }

                        Source https://phpmd.org/rules/cleancode.html#elseexpression

                        The method get_object_total uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                        Open

                                } else {
                                    $sql = "SELECT COUNT(*) AS `total_count` FROM `object_count` WHERE `object_type` = ? AND `object_id` = ? AND `count_type` = ?";
                                    if ($threshold > 0) {
                                        $date = time() - (86400 * (int)$threshold);
                                        $sql .= "AND `date` >= '" . $date . "'";
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        ElseExpression

                        Since: 1.4.0

                        An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                        Example

                        class Foo
                        {
                            public function bar($flag)
                            {
                                if ($flag) {
                                    // one branch
                                } else {
                                    // another branch
                                }
                            }
                        }

                        Source https://phpmd.org/rules/cleancode.html#elseexpression

                        The method get_top_sql uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                        Open

                                    } else {
                                        $sql .= " WHERE `object_count`.`object_type` = '" . $type . "' ";
                                    }
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        ElseExpression

                        Since: 1.4.0

                        An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                        Example

                        class Foo
                        {
                            public function bar($flag)
                            {
                                if ($flag) {
                                    // one branch
                                } else {
                                    // another branch
                                }
                            }
                        }

                        Source https://phpmd.org/rules/cleancode.html#elseexpression

                        The method get_newest_sql uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                        Open

                                } else {
                                    $sql .= "GROUP BY $sql_type ORDER BY `real_atime` DESC ";
                                }
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        ElseExpression

                        Since: 1.4.0

                        An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                        Example

                        class Foo
                        {
                            public function bar($flag)
                            {
                                if ($flag) {
                                    // one branch
                                } else {
                                    // another branch
                                }
                            }
                        }

                        Source https://phpmd.org/rules/cleancode.html#elseexpression

                        Avoid assigning values to variables in if clauses and the like (line '160', column '17').
                        Open

                            public static function delete(int $activity_id): void
                            {
                                if ($activity_id > 0) {
                                    $sql        = "SELECT `object_count`.`object_id`, `object_count`.`object_type`, `object_count`.`date`, `object_count`.`user`, `object_count`.`agent`, `object_count`.`count_type` FROM `object_count` WHERE `object_count`.`id` = ?;";
                                    $db_results = Dba::read($sql, array($activity_id));
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        IfStatementAssignment

                        Since: 2.7.0

                        Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

                        Example

                        class Foo
                        {
                            public function bar($flag)
                            {
                                if ($foo = 'bar') { // possible typo
                                    // ...
                                }
                                if ($baz = 0) { // always false
                                    // ...
                                }
                            }
                        }

                        Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

                        Avoid unused local variables such as '$filter_type'.
                        Open

                                $filter_type = $type;
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        UnusedLocalVariable

                        Since: 0.2

                        Detects when a local variable is declared and/or assigned, but not used.

                        Example

                        class Foo {
                            public function doSomething()
                            {
                                $i = 5; // Unused
                            }
                        }

                        Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

                        FIXME found
                        Open

                                // FIXME:: Requires table scan, look at improving
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by fixme

                        syntax error, unexpected 'int' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST)
                        Open

                            public int $id = 0;
                        Severity: Critical
                        Found in src/Module/Statistics/Stats.php by phan

                        Similar blocks of code found in 2 locations. Consider refactoring.
                        Open

                            public static function duplicate_map(string $source_type, int $source_id, string $dest_type, int $dest_id): void
                            {
                                if ($source_id > 0 && $dest_id > 0) {
                                    debug_event(__CLASS__, "duplicate_map " . $source_type . " {" . $source_id . "} => " . $dest_type . " {" . $dest_id . "}", 5);
                                    $sql        = "SELECT `object_count`.`date`, `object_count`.`user`, `object_count`.`agent`, `object_count`.`geo_latitude`, `object_count`.`geo_longitude`, `object_count`.`geo_name`, `object_count`.`count_type` FROM `object_count` WHERE `object_count`.`count_type` = 'stream' AND `object_count`.`object_type` = ? AND `object_count`.`object_id` = ?;";
                        Severity: Major
                        Found in src/Module/Statistics/Stats.php and 1 other location - About 6 hrs to fix
                        src/Module/Statistics/Stats.php on lines 139..150

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 207.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Similar blocks of code found in 2 locations. Consider refactoring.
                        Open

                            public static function delete_map(string $source_type, int $source_id, string $dest_type, int $dest_id): void
                            {
                                if ($source_id > 0 && $dest_id > 0) {
                                    debug_event(__CLASS__, "delete_map " . $source_type . " {" . $source_id . "} => " . $dest_type . " {" . $dest_id . "}", 5);
                                    $sql        = "SELECT `object_count`.`date`, `object_count`.`user`, `object_count`.`agent`, `object_count`.`geo_latitude`, `object_count`.`geo_longitude`, `object_count`.`geo_name`, `object_count`.`count_type` FROM `object_count` WHERE `object_count`.`count_type` = 'stream' AND `object_count`.`object_type` = ? AND `object_count`.`object_id` = ?;";
                        Severity: Major
                        Found in src/Module/Statistics/Stats.php and 1 other location - About 6 hrs to fix
                        src/Module/Statistics/Stats.php on lines 123..134

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 207.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        The parameter $object_id is not named in camelCase.
                        Open

                            public static function is_already_inserted($type, $object_id, $user, $agent, $time, $exact = false): bool
                            {
                                $sql = ($exact)
                                    ? "SELECT `object_id`, `date`, `count_type` FROM `object_count` WHERE `object_count`.`user` = ? AND `object_count`.`object_type` = ? AND `object_count`.`count_type` = 'stream' AND `object_count`.`date` = $time "
                                    : "SELECT `object_id`, `date`, `count_type` FROM `object_count` WHERE `object_count`.`user` = ? AND `object_count`.`object_type` = ? AND `object_count`.`count_type` = 'stream' AND (`object_count`.`date` >= ($time - 5) AND `object_count`.`date` <= ($time + 5)) ";
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $user_id is not named in camelCase.
                        Open

                            public static function get_recently_played($user_id, $count_type = 'stream', $object_type = null, $user_only = false): array
                            {
                                $personal_info_recent = 91;
                                $personal_info_time   = 92;
                                $personal_info_agent  = 93;
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $input_type is not named in camelCase.
                        Open

                            public static function get_recent_sql($input_type, $user_id = null, $newest = true): string
                            {
                                $type           = self::validate_type($input_type);
                                $ordersql       = ($newest === true) ? 'DESC' : 'ASC';
                                $user_sql       = (!empty($user_id)) ? " AND `user` = '" . $user_id . "'" : '';
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $dest_id is not named in camelCase.
                        Open

                            public static function delete_map(string $source_type, int $source_id, string $dest_type, int $dest_id): void
                            {
                                if ($source_id > 0 && $dest_id > 0) {
                                    debug_event(__CLASS__, "delete_map " . $source_type . " {" . $source_id . "} => " . $dest_type . " {" . $dest_id . "}", 5);
                                    $sql        = "SELECT `object_count`.`date`, `object_count`.`user`, `object_count`.`agent`, `object_count`.`geo_latitude`, `object_count`.`geo_longitude`, `object_count`.`geo_name`, `object_count`.`count_type` FROM `object_count` WHERE `object_count`.`count_type` = 'stream' AND `object_count`.`object_type` = ? AND `object_count`.`object_id` = ?;";
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $user_id is not named in camelCase.
                        Open

                            public static function insert(
                                $input_type,
                                $object_id,
                                $user_id,
                                $agent = '',
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $object_id is not named in camelCase.
                        Open

                            public static function get_object_count($object_type, $object_id, $threshold = null, $count_type = 'stream'): int
                            {
                                if ($threshold === null || $threshold === '') {
                                    $threshold = 0;
                                }
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $user_id is not named in camelCase.
                        Open

                            public static function shift_last_play($user_id, $agent, $original_date, $new_date): void
                            {
                                // update the object_count table
                                $sql = "UPDATE `object_count` SET `object_count`.`date` = ? WHERE `object_count`.`user` = ? AND `object_count`.`agent` = ? AND `object_count`.`date` = ?";
                                Dba::write($sql, array($new_date, $user_id, $agent, $original_date));
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $object_id is not named in camelCase.
                        Open

                            public static function skip_last_play($date, $agent, $user_id, $object_id, $object_type)
                            {
                                // change from a stream to a skip
                                $sql = "UPDATE `object_count` SET `count_type` = 'skip' WHERE `date` = ? AND `agent` = ? AND `user` = ? AND `object_count`.`object_type` = ? ORDER BY `object_count`.`date` DESC";
                                Dba::write($sql, array($date, $agent, $user_id, $object_type));
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $input_type is not named in camelCase.
                        Open

                            public static function get_top_sql(
                                $input_type,
                                $threshold,
                                $count_type = 'stream',
                                $user_id = null,
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $object_id is not named in camelCase.
                        Open

                            public static function count(string $type, int $object_id, string $count_type): void
                            {
                                switch ($type) {
                                    case 'song':
                                    case 'podcast':
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $catalog_id is not named in camelCase.
                        Open

                            public static function get_newest_sql($input_type, $catalog_id = 0, $user_id = null): string
                            {
                                $type = self::validate_type($input_type);
                                // all objects could be filtered
                                $catalog_filter = (AmpConfig::get('catalog_filter'));
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $old_object_id is not named in camelCase.
                        Open

                            public static function migrate($object_type, $old_object_id, $new_object_id, $child_id)
                            {
                                if (!in_array($object_type, array('song', 'album', 'artist', 'video', 'live_stream', 'playlist', 'podcast', 'podcast_episode', 'tvshow'))) {
                                    return false;
                                }
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $count_type is not named in camelCase.
                        Open

                            public static function count(string $type, int $object_id, string $count_type): void
                            {
                                switch ($type) {
                                    case 'song':
                                    case 'podcast':
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $object_id is not named in camelCase.
                        Open

                            public static function get_time($object_id, $object_type): int
                            {
                                // you can't get the last played when you haven't played something before
                                if (!$object_id || !$object_type) {
                                    return 0;
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $object_type is not named in camelCase.
                        Open

                            public static function get_time($object_id, $object_type): int
                            {
                                // you can't get the last played when you haven't played something before
                                if (!$object_id || !$object_type) {
                                    return 0;
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $user_id is not named in camelCase.
                        Open

                            public static function clear($user_id = 0): void
                            {
                                if ($user_id > 0) {
                                    Dba::write("DELETE FROM `object_count` WHERE `user` = ?;", array($user_id));
                                } else {
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $dest_type is not named in camelCase.
                        Open

                            public static function delete_map(string $source_type, int $source_id, string $dest_type, int $dest_id): void
                            {
                                if ($source_id > 0 && $dest_id > 0) {
                                    debug_event(__CLASS__, "delete_map " . $source_type . " {" . $source_id . "} => " . $dest_type . " {" . $dest_id . "}", 5);
                                    $sql        = "SELECT `object_count`.`date`, `object_count`.`user`, `object_count`.`agent`, `object_count`.`geo_latitude`, `object_count`.`geo_longitude`, `object_count`.`geo_name`, `object_count`.`count_type` FROM `object_count` WHERE `object_count`.`count_type` = 'stream' AND `object_count`.`object_type` = ? AND `object_count`.`object_id` = ?;";
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $object_type is not named in camelCase.
                        Open

                            public static function skip_last_play($date, $agent, $user_id, $object_id, $object_type)
                            {
                                // change from a stream to a skip
                                $sql = "UPDATE `object_count` SET `count_type` = 'skip' WHERE `date` = ? AND `agent` = ? AND `user` = ? AND `object_count`.`object_type` = ? ORDER BY `object_count`.`date` DESC";
                                Dba::write($sql, array($date, $agent, $user_id, $object_type));
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $input_type is not named in camelCase.
                        Open

                            public static function get_recent($input_type, $count = 0, $offset = 0, $newest = true): array
                            {
                                if ($count === 0) {
                                    $count = AmpConfig::get('popular_threshold', 10);
                                }
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $count_type is not named in camelCase.
                        Open

                            public static function get_recently_played($user_id, $count_type = 'stream', $object_type = null, $user_only = false): array
                            {
                                $personal_info_recent = 91;
                                $personal_info_time   = 92;
                                $personal_info_agent  = 93;
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $object_id is not named in camelCase.
                        Open

                            public static function insert(
                                $input_type,
                                $object_id,
                                $user_id,
                                $agent = '',
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $object_type is not named in camelCase.
                        Open

                            public static function get_object_total($object_type, $object_id, $threshold = null, $count_type = 'stream'): int
                            {
                                if ($threshold === null || $threshold === '') {
                                    $threshold = 0;
                                }
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $user_only is not named in camelCase.
                        Open

                            public static function get_recently_played($user_id, $count_type = 'stream', $object_type = null, $user_only = false): array
                            {
                                $personal_info_recent = 91;
                                $personal_info_time   = 92;
                                $personal_info_agent  = 93;
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $user_id is not named in camelCase.
                        Open

                            public static function get_newest_sql($input_type, $catalog_id = 0, $user_id = null): string
                            {
                                $type = self::validate_type($input_type);
                                // all objects could be filtered
                                $catalog_filter = (AmpConfig::get('catalog_filter'));
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $dest_id is not named in camelCase.
                        Open

                            public static function duplicate_map(string $source_type, int $source_id, string $dest_type, int $dest_id): void
                            {
                                if ($source_id > 0 && $dest_id > 0) {
                                    debug_event(__CLASS__, "duplicate_map " . $source_type . " {" . $source_id . "} => " . $dest_type . " {" . $dest_id . "}", 5);
                                    $sql        = "SELECT `object_count`.`date`, `object_count`.`user`, `object_count`.`agent`, `object_count`.`geo_latitude`, `object_count`.`geo_longitude`, `object_count`.`geo_name`, `object_count`.`count_type` FROM `object_count` WHERE `object_count`.`count_type` = 'stream' AND `object_count`.`object_type` = ? AND `object_count`.`object_id` = ?;";
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $user_id is not named in camelCase.
                        Open

                            public static function get_last_play($user_id = 0, $agent = '', $date = 0): array
                            {
                                if ($user_id === 0) {
                                    $user    = Core::get_global('user');
                                    $user_id = $user->id ?? 0;
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $original_date is not named in camelCase.
                        Open

                            public static function shift_last_play($user_id, $agent, $original_date, $new_date): void
                            {
                                // update the object_count table
                                $sql = "UPDATE `object_count` SET `object_count`.`date` = ? WHERE `object_count`.`user` = ? AND `object_count`.`agent` = ? AND `object_count`.`date` = ?";
                                Dba::write($sql, array($new_date, $user_id, $agent, $original_date));
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $new_date is not named in camelCase.
                        Open

                            public static function shift_last_play($user_id, $agent, $original_date, $new_date): void
                            {
                                // update the object_count table
                                $sql = "UPDATE `object_count` SET `object_count`.`date` = ? WHERE `object_count`.`user` = ? AND `object_count`.`agent` = ? AND `object_count`.`date` = ?";
                                Dba::write($sql, array($new_date, $user_id, $agent, $original_date));
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $user_id is not named in camelCase.
                        Open

                            public static function get_object_history($user_id, $time, $newest = true): array
                            {
                                if (!in_array((string)$user_id, static::getUserRepository()->getValid())) {
                                    $user    = Core::get_global('user');
                                    $user_id = $user->id ?? 0;
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $user_id is not named in camelCase.
                        Open

                            public static function get_top($input_type, $count, $threshold, $offset = 0, $user_id = null, $random = false, $since = 0, $before = 0): array
                            {
                                if ($count === 0) {
                                    $count = AmpConfig::get('popular_threshold', 10);
                                }
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $user_id is not named in camelCase.
                        Open

                            public static function get_object_data($dataType, $startTime, $endTime, $user_id): string
                            {
                                $params = array($startTime, $endTime, $user_id);
                                switch ($dataType) {
                                    case 'song_count':
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $count_type is not named in camelCase.
                        Open

                            public static function get_object_total($object_type, $object_id, $threshold = null, $count_type = 'stream'): int
                            {
                                if ($threshold === null || $threshold === '') {
                                    $threshold = 0;
                                }
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $object_type is not named in camelCase.
                        Open

                            public static function get_recently_played($user_id, $count_type = 'stream', $object_type = null, $user_only = false): array
                            {
                                $personal_info_recent = 91;
                                $personal_info_time   = 92;
                                $personal_info_agent  = 93;
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $source_id is not named in camelCase.
                        Open

                            public static function duplicate_map(string $source_type, int $source_id, string $dest_type, int $dest_id): void
                            {
                                if ($source_id > 0 && $dest_id > 0) {
                                    debug_event(__CLASS__, "duplicate_map " . $source_type . " {" . $source_id . "} => " . $dest_type . " {" . $dest_id . "}", 5);
                                    $sql        = "SELECT `object_count`.`date`, `object_count`.`user`, `object_count`.`agent`, `object_count`.`geo_latitude`, `object_count`.`geo_longitude`, `object_count`.`geo_name`, `object_count`.`count_type` FROM `object_count` WHERE `object_count`.`count_type` = 'stream' AND `object_count`.`object_type` = ? AND `object_count`.`object_id` = ?;";
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $count_type is not named in camelCase.
                        Open

                            public static function get_top_sql(
                                $input_type,
                                $threshold,
                                $count_type = 'stream',
                                $user_id = null,
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $object_type is not named in camelCase.
                        Open

                            public static function has_played_history($object_type, $object, $user_id, $agent, $date): bool
                            {
                                if (AmpConfig::get('use_auth') && $user_id == -1) {
                                    return false;
                                }
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $source_type is not named in camelCase.
                        Open

                            public static function delete_map(string $source_type, int $source_id, string $dest_type, int $dest_id): void
                            {
                                if ($source_id > 0 && $dest_id > 0) {
                                    debug_event(__CLASS__, "delete_map " . $source_type . " {" . $source_id . "} => " . $dest_type . " {" . $dest_id . "}", 5);
                                    $sql        = "SELECT `object_count`.`date`, `object_count`.`user`, `object_count`.`agent`, `object_count`.`geo_latitude`, `object_count`.`geo_longitude`, `object_count`.`geo_name`, `object_count`.`count_type` FROM `object_count` WHERE `object_count`.`count_type` = 'stream' AND `object_count`.`object_type` = ? AND `object_count`.`object_id` = ?;";
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $input_type is not named in camelCase.
                        Open

                            public static function get_newest($input_type, $count = 0, $offset = 0, $catalog_id = 0, $user_id = null): array
                            {
                                if ($count === 0) {
                                    $count = AmpConfig::get('popular_threshold', 10);
                                }
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $user_id is not named in camelCase.
                        Open

                            public static function get_newest($input_type, $count = 0, $offset = 0, $catalog_id = 0, $user_id = null): array
                            {
                                if ($count === 0) {
                                    $count = AmpConfig::get('popular_threshold', 10);
                                }
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        Avoid variables with short names like $id. Configured minimum length is 3.
                        Open

                            public int $id = 0;
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        ShortVariable

                        Since: 0.2

                        Detects when a field, local, or parameter has a very short name.

                        Example

                        class Something {
                            private $q = 15; // VIOLATION - Field
                            public static function main( array $as ) { // VIOLATION - Formal
                                $r = 20 + $this->q; // VIOLATION - Local
                                for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                                    $r += $this->q;
                                }
                            }
                        }

                        Source https://phpmd.org/rules/naming.html#shortvariable

                        The parameter $input_type is not named in camelCase.
                        Open

                            public static function insert(
                                $input_type,
                                $object_id,
                                $user_id,
                                $agent = '',
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $object_type is not named in camelCase.
                        Open

                            public static function get_object_count($object_type, $object_id, $threshold = null, $count_type = 'stream'): int
                            {
                                if ($threshold === null || $threshold === '') {
                                    $threshold = 0;
                                }
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $catalog_id is not named in camelCase.
                        Open

                            public static function get_newest($input_type, $count = 0, $offset = 0, $catalog_id = 0, $user_id = null): array
                            {
                                if ($count === 0) {
                                    $count = AmpConfig::get('popular_threshold', 10);
                                }
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $new_object_id is not named in camelCase.
                        Open

                            public static function migrate($object_type, $old_object_id, $new_object_id, $child_id)
                            {
                                if (!in_array($object_type, array('song', 'album', 'artist', 'video', 'live_stream', 'playlist', 'podcast', 'podcast_episode', 'tvshow'))) {
                                    return false;
                                }
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $count_type is not named in camelCase.
                        Open

                            public static function insert(
                                $input_type,
                                $object_id,
                                $user_id,
                                $agent = '',
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $user_id is not named in camelCase.
                        Open

                            public static function skip_last_play($date, $agent, $user_id, $object_id, $object_type)
                            {
                                // change from a stream to a skip
                                $sql = "UPDATE `object_count` SET `count_type` = 'skip' WHERE `date` = ? AND `agent` = ? AND `user` = ? AND `object_count`.`object_type` = ? ORDER BY `object_count`.`date` DESC";
                                Dba::write($sql, array($date, $agent, $user_id, $object_type));
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $user_id is not named in camelCase.
                        Open

                            public static function has_played_history($object_type, $object, $user_id, $agent, $date): bool
                            {
                                if (AmpConfig::get('use_auth') && $user_id == -1) {
                                    return false;
                                }
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $input_type is not named in camelCase.
                        Open

                            public static function get_user($count, $input_type, $user, $full = 0): array
                            {
                                $type = self::validate_type($input_type);
                        
                                // If full then don't limit on date
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $child_id is not named in camelCase.
                        Open

                            public static function migrate($object_type, $old_object_id, $new_object_id, $child_id)
                            {
                                if (!in_array($object_type, array('song', 'album', 'artist', 'video', 'live_stream', 'playlist', 'podcast', 'podcast_episode', 'tvshow'))) {
                                    return false;
                                }
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $count_type is not named in camelCase.
                        Open

                            public static function get_object_count($object_type, $object_id, $threshold = null, $count_type = 'stream'): int
                            {
                                if ($threshold === null || $threshold === '') {
                                    $threshold = 0;
                                }
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $user_id is not named in camelCase.
                        Open

                            public static function get_recent_sql($input_type, $user_id = null, $newest = true): string
                            {
                                $type           = self::validate_type($input_type);
                                $ordersql       = ($newest === true) ? 'DESC' : 'ASC';
                                $user_sql       = (!empty($user_id)) ? " AND `user` = '" . $user_id . "'" : '';
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $object_type is not named in camelCase.
                        Open

                            public static function migrate($object_type, $old_object_id, $new_object_id, $child_id)
                            {
                                if (!in_array($object_type, array('song', 'album', 'artist', 'video', 'live_stream', 'playlist', 'podcast', 'podcast_episode', 'tvshow'))) {
                                    return false;
                                }
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $source_type is not named in camelCase.
                        Open

                            public static function duplicate_map(string $source_type, int $source_id, string $dest_type, int $dest_id): void
                            {
                                if ($source_id > 0 && $dest_id > 0) {
                                    debug_event(__CLASS__, "duplicate_map " . $source_type . " {" . $source_id . "} => " . $dest_type . " {" . $dest_id . "}", 5);
                                    $sql        = "SELECT `object_count`.`date`, `object_count`.`user`, `object_count`.`agent`, `object_count`.`geo_latitude`, `object_count`.`geo_longitude`, `object_count`.`geo_name`, `object_count`.`count_type` FROM `object_count` WHERE `object_count`.`count_type` = 'stream' AND `object_count`.`object_type` = ? AND `object_count`.`object_id` = ?;";
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $dest_type is not named in camelCase.
                        Open

                            public static function duplicate_map(string $source_type, int $source_id, string $dest_type, int $dest_id): void
                            {
                                if ($source_id > 0 && $dest_id > 0) {
                                    debug_event(__CLASS__, "duplicate_map " . $source_type . " {" . $source_id . "} => " . $dest_type . " {" . $dest_id . "}", 5);
                                    $sql        = "SELECT `object_count`.`date`, `object_count`.`user`, `object_count`.`agent`, `object_count`.`geo_latitude`, `object_count`.`geo_longitude`, `object_count`.`geo_name`, `object_count`.`count_type` FROM `object_count` WHERE `object_count`.`count_type` = 'stream' AND `object_count`.`object_type` = ? AND `object_count`.`object_id` = ?;";
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $source_id is not named in camelCase.
                        Open

                            public static function delete_map(string $source_type, int $source_id, string $dest_type, int $dest_id): void
                            {
                                if ($source_id > 0 && $dest_id > 0) {
                                    debug_event(__CLASS__, "delete_map " . $source_type . " {" . $source_id . "} => " . $dest_type . " {" . $dest_id . "}", 5);
                                    $sql        = "SELECT `object_count`.`date`, `object_count`.`user`, `object_count`.`agent`, `object_count`.`geo_latitude`, `object_count`.`geo_longitude`, `object_count`.`geo_name`, `object_count`.`count_type` FROM `object_count` WHERE `object_count`.`count_type` = 'stream' AND `object_count`.`object_type` = ? AND `object_count`.`object_id` = ?;";
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $activity_id is not named in camelCase.
                        Open

                            public static function delete(int $activity_id): void
                            {
                                if ($activity_id > 0) {
                                    $sql        = "SELECT `object_count`.`object_id`, `object_count`.`object_type`, `object_count`.`date`, `object_count`.`user`, `object_count`.`agent`, `object_count`.`count_type` FROM `object_count` WHERE `object_count`.`id` = ?;";
                                    $db_results = Dba::read($sql, array($activity_id));
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $object_id is not named in camelCase.
                        Open

                            public static function get_object_total($object_type, $object_id, $threshold = null, $count_type = 'stream'): int
                            {
                                if ($threshold === null || $threshold === '') {
                                    $threshold = 0;
                                }
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $user_id is not named in camelCase.
                        Open

                            public static function get_top_sql(
                                $input_type,
                                $threshold,
                                $count_type = 'stream',
                                $user_id = null,
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $input_type is not named in camelCase.
                        Open

                            public static function get_top($input_type, $count, $threshold, $offset = 0, $user_id = null, $random = false, $since = 0, $before = 0): array
                            {
                                if ($count === 0) {
                                    $count = AmpConfig::get('popular_threshold', 10);
                                }
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        The parameter $input_type is not named in camelCase.
                        Open

                            public static function get_newest_sql($input_type, $catalog_id = 0, $user_id = null): string
                            {
                                $type = self::validate_type($input_type);
                                // all objects could be filtered
                                $catalog_filter = (AmpConfig::get('catalog_filter'));
                        Severity: Minor
                        Found in src/Module/Statistics/Stats.php by phpmd

                        CamelCaseParameterName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name parameters.

                        Example

                        class ClassName {
                            public function doSomething($user_name) {
                            }
                        }

                        Source

                        Blank line found at start of control structure
                        Open

                                if (isset($results['data'])) {

                        There are no issues that match your filters.

                        Category
                        Status