ampache/ampache

View on GitHub
src/Repository/Model/Playlist.php

Summary

Maintainability
D
2 days
Test Coverage

Playlist has 37 functions (exceeds 20 allowed). Consider refactoring.
Open

class Playlist extends playlist_object
{
    protected const DB_TABLENAME = 'playlist';

    /* Generated Elements */
Severity: Minor
Found in src/Repository/Model/Playlist.php - About 4 hrs to fix

    File Playlist.php has 607 lines of code (exceeds 500 allowed). Consider refactoring.
    Open

    <?php
    
    declare(strict_types=0);
    
    /**
    Severity: Major
    Found in src/Repository/Model/Playlist.php - About 4 hrs to fix

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

      class Playlist extends playlist_object
      {
          protected const DB_TABLENAME = 'playlist';
      
          /* Generated Elements */
      Severity: Minor
      Found in src/Repository/Model/Playlist.php by phpmd

      The class Playlist has 18 public methods. Consider refactoring Playlist to keep number of public methods under 10.
      Open

      class Playlist extends playlist_object
      {
          protected const DB_TABLENAME = 'playlist';
      
          /* Generated Elements */
      Severity: Minor
      Found in src/Repository/Model/Playlist.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_playlists has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function get_playlists($user_id = null, $playlist_name = '', $like = true, $includePublic = true, $includeHidden = true, $userOnly = false): array
          {
              if (!$user_id) {
                  $user    = Core::get_global('user');
                  $user_id = $user->id ?? 0;
      Severity: Minor
      Found in src/Repository/Model/Playlist.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_items has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          public function get_items(): array
          {
              if ($this->isNew()) {
                  return array();
              }
      Severity: Minor
      Found in src/Repository/Model/Playlist.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_media_count has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          public function get_media_count($type = ''): int
          {
              $user      = Core::get_global('user');
              $user_id   = $user->id ?? 0;
              $params    = array($this->id);
      Severity: Minor
      Found in src/Repository/Model/Playlist.php - About 55 mins to fix

      Cognitive Complexity

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

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

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

      Further reading

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

          public function has_item($object = null, $track = null): bool
          {
              if ($object === null && $track === null) {
                  return false;
              }
      Severity: Minor
      Found in src/Repository/Model/Playlist.php - About 55 mins to fix

      Cognitive Complexity

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

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

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

      Further reading

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

          public static function get_playlists($user_id = null, $playlist_name = '', $like = true, $includePublic = true, $includeHidden = true, $userOnly = false): array
      Severity: Minor
      Found in src/Repository/Model/Playlist.php - About 45 mins to fix

        Function get_random_items has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            public function get_random_items($limit = ''): array
            {
                $results = array();
                $user    = Core::get_global('user');
                $user_id = $user->id ?? 0;
        Severity: Minor
        Found in src/Repository/Model/Playlist.php - About 45 mins to fix

        Cognitive Complexity

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

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

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

        Further reading

        Function add_medias has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            public function add_medias($medias): bool
            {
                if (empty($medias)) {
                    return false;
                }
        Severity: Minor
        Found in src/Repository/Model/Playlist.php - About 45 mins to fix

        Cognitive Complexity

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

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

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

        Further reading

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

            public function update(array $data): int
            {
                if (isset($data['name']) && $data['name'] != $this->name) {
                    $this->_update_name($data['name']);
                }
        Severity: Minor
        Found in src/Repository/Model/Playlist.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_playlist_array has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function get_playlist_array($user_id = 0): array
            {
                if ($user_id === 0) {
                    $user    = Core::get_global('user');
                    $user_id = $user->id ?? 0;
        Severity: Minor
        Found in src/Repository/Model/Playlist.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 has_search has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function has_search($playlist_user): int
            {
                // search for your own playlist
                $sql        = "SELECT `id`, `name` FROM `search` WHERE `user` = ?";
                $db_results = Dba::read($sql, array($playlist_user));
        Severity: Minor
        Found in src/Repository/Model/Playlist.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 create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function create($name, $type, $user_id = null, $existing = true): ?int
            {
                if ($user_id === null) {
                    $user    = Core::get_global('user');
                    $user_id = $user->id ?? -1;
        Severity: Minor
        Found in src/Repository/Model/Playlist.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 update() has an NPath complexity of 243. The configured NPath complexity threshold is 200.
        Open

            public function update(array $data): int
            {
                if (isset($data['name']) && $data['name'] != $this->name) {
                    $this->_update_name($data['name']);
                }
        Severity: Minor
        Found in src/Repository/Model/Playlist.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_playlists() has an NPath complexity of 1728. The configured NPath complexity threshold is 200.
        Open

            public static function get_playlists($user_id = null, $playlist_name = '', $like = true, $includePublic = true, $includeHidden = true, $userOnly = false): array
            {
                if (!$user_id) {
                    $user    = Core::get_global('user');
                    $user_id = $user->id ?? 0;
        Severity: Minor
        Found in src/Repository/Model/Playlist.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_random_items() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10.
        Open

            public function get_random_items($limit = ''): array
            {
                $results = array();
                $user    = Core::get_global('user');
                $user_id = $user->id ?? 0;
        Severity: Minor
        Found in src/Repository/Model/Playlist.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_playlists() has a Cyclomatic Complexity of 16. The configured cyclomatic complexity threshold is 10.
        Open

            public static function get_playlists($user_id = null, $playlist_name = '', $like = true, $includePublic = true, $includeHidden = true, $userOnly = false): array
            {
                if (!$user_id) {
                    $user    = Core::get_global('user');
                    $user_id = $user->id ?? 0;
        Severity: Minor
        Found in src/Repository/Model/Playlist.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_items() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10.
        Open

            public function get_items(): array
            {
                if ($this->isNew()) {
                    return array();
                }
        Severity: Minor
        Found in src/Repository/Model/Playlist.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 update() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10.
        Open

            public function update(array $data): int
            {
                if (isset($data['name']) && $data['name'] != $this->name) {
                    $this->_update_name($data['name']);
                }
        Severity: Minor
        Found in src/Repository/Model/Playlist.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

        Refactor this function to reduce its Cognitive Complexity from 18 to the 15 allowed.
        Open

            public static function get_playlists($user_id = null, $playlist_name = '', $like = true, $includePublic = true, $includeHidden = true, $userOnly = false): array
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by sonar-php

        Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

        See

        Reduce the number of returns of this function 4, down to the maximum allowed 3.
        Open

            public static function create($name, $type, $user_id = null, $existing = true): ?int
        Severity: Major
        Found in src/Repository/Model/Playlist.php by sonar-php

        Having too many return statements in a function increases the function's essential complexity because the flow of execution is broken each time a return statement is encountered. This makes it harder to read and understand the logic of the function.

        Noncompliant Code Example

        With the default threshold of 3:

        function myFunction(){ // Noncompliant as there are 4 return statements
          if (condition1) {
            return true;
          } else {
            if (condition2) {
              return false;
            } else {
              return true;
            }
          }
          return false;
        }
        

        Class "Playlist" has 37 methods, which is greater than 20 authorized. Split it into smaller classes.
        Open

        class Playlist extends playlist_object
        Severity: Major
        Found in src/Repository/Model/Playlist.php by sonar-php

        A class that grows too much tends to aggregate too many responsibilities and inevitably becomes harder to understand and therefore to maintain. Above a specific threshold, it is strongly advised to refactor the class into smaller ones which focus on well defined topics.

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

                    } else {
                        $sql .= "AND `playlist_data`.`object_type` = '$type' AND `$type`.`catalog` IN (SELECT `catalog_id` FROM `catalog_filter_group_map` INNER JOIN `user` ON `user`.`catalog_filter_group` = `catalog_filter_group_map`.`group_id` WHERE `user`.`id` = ? AND `catalog_filter_group_map`.`enabled`=1) ";
                        $params[] = $user_id;
                    }
        Severity: Minor
        Found in src/Repository/Model/Playlist.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 has_item uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
        Open

                } else {
                    if ($track !== null) {
                        $sql        = "SELECT `object_id` FROM `playlist_data` WHERE `playlist_data`.`playlist` = ? AND `playlist_data`.`object_id` = ? AND `playlist_data`.`object_type` = 'song' AND `track` <= ? LIMIT 1";
                        $db_results = Dba::read($sql, array($this->id, $object, $track));
                    } else {
        Severity: Minor
        Found in src/Repository/Model/Playlist.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_media_count uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
        Open

                } else {
                    // check for a specific type of object
                    $sql = 'SELECT COUNT(`playlist_data`.`id`) AS `list_count` FROM `playlist_data` INNER JOIN `' . $type . '` ON `playlist_data`.`object_id` = `' . $type . '`.`id` WHERE `playlist_data`.`playlist` = ? AND `object_id` IS NOT NULL ';
                }
        Severity: Minor
        Found in src/Repository/Model/Playlist.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 create uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
        Open

                    } else {
                        return $existing_id;
                    }
        Severity: Minor
        Found in src/Repository/Model/Playlist.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 has_item uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
        Open

                    } else {
                        // Search object and optionally check by track
                        $sql        = "SELECT `object_id` FROM `playlist_data` WHERE `playlist_data`.`playlist` = ? AND `playlist_data`.`object_id` = ? AND `playlist_data`.`object_type` = 'song' LIMIT 1";
                        $db_results = Dba::read($sql, array($this->id, $object));
                    }
        Severity: Minor
        Found in src/Repository/Model/Playlist.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 add_medias uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
        Open

                    } else {
                        $count++;
                        $track = $base_track + $count;
                        $sql .= "(?, ?, ?, ?), ";
                        $values[] = $this->id;
        Severity: Minor
        Found in src/Repository/Model/Playlist.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

        Remove this commented out code.
        Open

                //debug_event(self::class, 'get_playlists query: ' . $sql, 5);
        Severity: Major
        Found in src/Repository/Model/Playlist.php by sonar-php

        Programmers should not comment out code as it bloats programs and reduces readability.

        Unused code should be deleted and can be retrieved from source control history if required.

        See

        • MISRA C:2004, 2.4 - Sections of code should not be "commented out".
        • MISRA C++:2008, 2-7-2 - Sections of code shall not be "commented out" using C-style comments.
        • MISRA C++:2008, 2-7-3 - Sections of code should not be "commented out" using C++ comments.
        • MISRA C:2012, Dir. 4.4 - Sections of code should not be "commented out"

        Define a constant instead of duplicating this literal "object_id" 11 times.
        Open

                            'object_id' => (int)$row['object_id'],
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by sonar-php

        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

        Noncompliant Code Example

        With the default threshold of 3:

        function run() {
          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
          execute('action1');
          release('action1');
        }
        

        Compliant Solution

        ACTION_1 = 'action1';
        
        function run() {
          prepare(ACTION_1);
          execute(ACTION_1);
          release(ACTION_1);
        }
        

        Exceptions

        To prevent generating some false-positives, literals having less than 5 characters are excluded.

        Define a constant instead of duplicating this literal "catalog_filter" 5 times.
        Open

                            if (AmpConfig::get('catalog_filter') && $user_id > 0) {
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by sonar-php

        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

        Noncompliant Code Example

        With the default threshold of 3:

        function run() {
          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
          execute('action1');
          release('action1');
        }
        

        Compliant Solution

        ACTION_1 = 'action1';
        
        function run() {
          prepare(ACTION_1);
          execute(ACTION_1);
          release(ACTION_1);
        }
        

        Exceptions

        To prevent generating some false-positives, literals having less than 5 characters are excluded.

        Define a constant instead of duplicating this literal "playlist" 5 times.
        Open

            protected const DB_TABLENAME = 'playlist';
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by sonar-php

        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

        Noncompliant Code Example

        With the default threshold of 3:

        function run() {
          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
          execute('action1');
          release('action1');
        }
        

        Compliant Solution

        ACTION_1 = 'action1';
        
        function run() {
          prepare(ACTION_1);
          execute(ACTION_1);
          release(ACTION_1);
        }
        

        Exceptions

        To prevent generating some false-positives, literals having less than 5 characters are excluded.

        Define a constant instead of duplicating this literal " from " 3 times.
        Open

                debug_event(self::class, 'Delete object_id: ' . $object_id . ' from ' . $this->id, 5);
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by sonar-php

        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

        Noncompliant Code Example

        With the default threshold of 3:

        function run() {
          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
          execute('action1');
          release('action1');
        }
        

        Compliant Solution

        ACTION_1 = 'action1';
        
        function run() {
          prepare(ACTION_1);
          execute(ACTION_1);
          release(ACTION_1);
        }
        

        Exceptions

        To prevent generating some false-positives, literals having less than 5 characters are excluded.

        Remove this commented out code.
        Open

                //debug_event(self::class, 'get_playlists query: ' . $sql, 5);
        Severity: Major
        Found in src/Repository/Model/Playlist.php by sonar-php

        Programmers should not comment out code as it bloats programs and reduces readability.

        Unused code should be deleted and can be retrieved from source control history if required.

        See

        • MISRA C:2004, 2.4 - Sections of code should not be "commented out".
        • MISRA C++:2008, 2-7-2 - Sections of code shall not be "commented out" using C-style comments.
        • MISRA C++:2008, 2-7-3 - Sections of code should not be "commented out" using C++ comments.
        • MISRA C:2012, Dir. 4.4 - Sections of code should not be "commented out"

        Define a constant instead of duplicating this literal "pl_user" 3 times.
        Open

                if (isset($data['pl_user']) && $data['pl_user'] != $this->user) {
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by sonar-php

        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

        Noncompliant Code Example

        With the default threshold of 3:

        function run() {
          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
          execute('action1');
          release('action1');
        }
        

        Compliant Solution

        ACTION_1 = 'action1';
        
        function run() {
          prepare(ACTION_1);
          execute(ACTION_1);
          release(ACTION_1);
        }
        

        Exceptions

        To prevent generating some false-positives, literals having less than 5 characters are excluded.

        Define a constant instead of duplicating this literal "last_count" 6 times.
        Open

                if (isset($data['last_count']) && $data['last_count'] != $this->last_count) {
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by sonar-php

        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

        Noncompliant Code Example

        With the default threshold of 3:

        function run() {
          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
          execute('action1');
          release('action1');
        }
        

        Compliant Solution

        ACTION_1 = 'action1';
        
        function run() {
          prepare(ACTION_1);
          execute(ACTION_1);
          release(ACTION_1);
        }
        

        Exceptions

        To prevent generating some false-positives, literals having less than 5 characters are excluded.

        Define a constant instead of duplicating this literal "video" 3 times.
        Open

                foreach (array('song', 'podcast_episode', 'video') as $object_type) {
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by sonar-php

        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

        Noncompliant Code Example

        With the default threshold of 3:

        function run() {
          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
          execute('action1');
          release('action1');
        }
        

        Compliant Solution

        ACTION_1 = 'action1';
        
        function run() {
          prepare(ACTION_1);
          execute(ACTION_1);
          release(ACTION_1);
        }
        

        Exceptions

        To prevent generating some false-positives, literals having less than 5 characters are excluded.

        Define a constant instead of duplicating this literal "ORDER BY playlist_data.track" 3 times.
        Open

                            $sql .= 'ORDER BY `playlist_data`.`track`';
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by sonar-php

        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

        Noncompliant Code Example

        With the default threshold of 3:

        function run() {
          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
          execute('action1');
          release('action1');
        }
        

        Compliant Solution

        ACTION_1 = 'action1';
        
        function run() {
          prepare(ACTION_1);
          execute(ACTION_1);
          release(ACTION_1);
        }
        

        Exceptions

        To prevent generating some false-positives, literals having less than 5 characters are excluded.

        Define a constant instead of duplicating this literal "track" 10 times.
        Open

                            'track' => (int)$row['track'],
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by sonar-php

        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

        Noncompliant Code Example

        With the default threshold of 3:

        function run() {
          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
          execute('action1');
          release('action1');
        }
        

        Compliant Solution

        ACTION_1 = 'action1';
        
        function run() {
          prepare(ACTION_1);
          execute(ACTION_1);
          release(ACTION_1);
        }
        

        Exceptions

        To prevent generating some false-positives, literals having less than 5 characters are excluded.

        Remove this commented out code.
        Open

                    // debug_event(__CLASS__, "get_items(): Results:\n" . print_r($results,true) , 5);
        Severity: Major
        Found in src/Repository/Model/Playlist.php by sonar-php

        Programmers should not comment out code as it bloats programs and reduces readability.

        Unused code should be deleted and can be retrieved from source control history if required.

        See

        • MISRA C:2004, 2.4 - Sections of code should not be "commented out".
        • MISRA C++:2008, 2-7-2 - Sections of code shall not be "commented out" using C-style comments.
        • MISRA C++:2008, 2-7-3 - Sections of code should not be "commented out" using C++ comments.
        • MISRA C:2012, Dir. 4.4 - Sections of code should not be "commented out"

        Remove this commented out code.
        Open

                //debug_event(__CLASS__, "get_media_count(): " . $sql . ' ' . print_r($params, true), 5);
        Severity: Major
        Found in src/Repository/Model/Playlist.php by sonar-php

        Programmers should not comment out code as it bloats programs and reduces readability.

        Unused code should be deleted and can be retrieved from source control history if required.

        See

        • MISRA C:2004, 2.4 - Sections of code should not be "commented out".
        • MISRA C++:2008, 2-7-2 - Sections of code shall not be "commented out" using C-style comments.
        • MISRA C++:2008, 2-7-3 - Sections of code should not be "commented out" using C++ comments.
        • MISRA C:2012, Dir. 4.4 - Sections of code should not be "commented out"

        Define a constant instead of duplicating this literal "object_type" 9 times.
        Open

                    $object_type = $row['object_type'];
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by sonar-php

        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

        Noncompliant Code Example

        With the default threshold of 3:

        function run() {
          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
          execute('action1');
          release('action1');
        }
        

        Compliant Solution

        ACTION_1 = 'action1';
        
        function run() {
          prepare(ACTION_1);
          execute(ACTION_1);
          release(ACTION_1);
        }
        

        Exceptions

        To prevent generating some false-positives, literals having less than 5 characters are excluded.

        Define a constant instead of duplicating this literal "last_duration" 6 times.
        Open

                if (isset($data['last_duration']) && $data['last_duration'] != $this->last_duration) {
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by sonar-php

        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

        Noncompliant Code Example

        With the default threshold of 3:

        function run() {
          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
          execute('action1');
          release('action1');
        }
        

        Compliant Solution

        ACTION_1 = 'action1';
        
        function run() {
          prepare(ACTION_1);
          execute(ACTION_1);
          release(ACTION_1);
        }
        

        Exceptions

        To prevent generating some false-positives, literals having less than 5 characters are excluded.

        Define a constant instead of duplicating this literal "podcast_episode" 4 times.
        Open

                foreach (array('song', 'podcast_episode', 'video') as $object_type) {
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by sonar-php

        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

        Noncompliant Code Example

        With the default threshold of 3:

        function run() {
          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
          execute('action1');
          release('action1');
        }
        

        Compliant Solution

        ACTION_1 = 'action1';
        
        function run() {
          prepare(ACTION_1);
          execute(ACTION_1);
          release(ACTION_1);
        }
        

        Exceptions

        To prevent generating some false-positives, literals having less than 5 characters are excluded.

        Remove this commented out code.
        Open

                    //debug_event(__CLASS__, "get_random_items(): " . $sql . $limit_sql, 5);
        Severity: Major
        Found in src/Repository/Model/Playlist.php by sonar-php

        Programmers should not comment out code as it bloats programs and reduces readability.

        Unused code should be deleted and can be retrieved from source control history if required.

        See

        • MISRA C:2004, 2.4 - Sections of code should not be "commented out".
        • MISRA C++:2008, 2-7-2 - Sections of code shall not be "commented out" using C-style comments.
        • MISRA C++:2008, 2-7-3 - Sections of code should not be "commented out" using C++ comments.
        • MISRA C:2012, Dir. 4.4 - Sections of code should not be "commented out"

        Remove this commented out code.
        Open

                // debug_event(__CLASS__, "get_total_duration(): " . $sql, 5);
        Severity: Major
        Found in src/Repository/Model/Playlist.php by sonar-php

        Programmers should not comment out code as it bloats programs and reduces readability.

        Unused code should be deleted and can be retrieved from source control history if required.

        See

        • MISRA C:2004, 2.4 - Sections of code should not be "commented out".
        • MISRA C++:2008, 2-7-2 - Sections of code shall not be "commented out" using C-style comments.
        • MISRA C++:2008, 2-7-3 - Sections of code should not be "commented out" using C++ comments.
        • MISRA C:2012, Dir. 4.4 - Sections of code should not be "commented out"

        Define a constant instead of duplicating this literal "interface" 3 times.
        Open

                $is_admin = ($userOnly === false || (Access::check('interface', 100, $user_id) || $user_id == -1));
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by sonar-php

        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

        Noncompliant Code Example

        With the default threshold of 3:

        function run() {
          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
          execute('action1');
          release('action1');
        }
        

        Compliant Solution

        ACTION_1 = 'action1';
        
        function run() {
          prepare(ACTION_1);
          execute(ACTION_1);
          release(ACTION_1);
        }
        

        Exceptions

        To prevent generating some false-positives, literals having less than 5 characters are excluded.

        Remove this commented out code.
        Open

                // debug_event(__CLASS__, "get_songs(): " . $sql, 5);
        Severity: Major
        Found in src/Repository/Model/Playlist.php by sonar-php

        Programmers should not comment out code as it bloats programs and reduces readability.

        Unused code should be deleted and can be retrieved from source control history if required.

        See

        • MISRA C:2004, 2.4 - Sections of code should not be "commented out".
        • MISRA C++:2008, 2-7-2 - Sections of code shall not be "commented out" using C-style comments.
        • MISRA C++:2008, 2-7-3 - Sections of code should not be "commented out" using C++ comments.
        • MISRA C:2012, Dir. 4.4 - Sections of code should not be "commented out"

        Merge this if statement with the enclosing one.
        Open

                    if ($user_id > 0 && parent::is_cached($key, $user_id)) {
        Severity: Major
        Found in src/Repository/Model/Playlist.php by sonar-php

        Merging collapsible if statements increases the code's readability.

        Noncompliant Code Example

        if (condition1) {
          if (condition2) {
            ...
          }
        }
        

        Compliant Solution

        if (condition1 && condition2) {
          ...
        }
        

        Define a constant instead of duplicating this literal "pl_type" 3 times.
        Open

                if (isset($data['pl_type']) && $data['pl_type'] != $this->type) {
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by sonar-php

        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

        Noncompliant Code Example

        With the default threshold of 3:

        function run() {
          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
          execute('action1');
          release('action1');
        }
        

        Compliant Solution

        ACTION_1 = 'action1';
        
        function run() {
          prepare(ACTION_1);
          execute(ACTION_1);
          release(ACTION_1);
        }
        

        Exceptions

        To prevent generating some false-positives, literals having less than 5 characters are excluded.

        TODO found
        Open

             * look for the track id or the object id in a playlist (TODO song only so extend this to other types)
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by fixme

        Reference to undeclared class \Ampache\Repository\Model\playlist_object
        Open

                parent::add_to_cache($key, $user_id, $results);
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Call to method write from undeclared class \Ampache\Module\System\Dba
        Open

                Dba::write("DELETE FROM `playlist_data` USING `playlist_data` LEFT JOIN `live_stream` ON `live_stream`.`id` = `playlist_data`.`object_id` WHERE `live_stream`.`id` IS NULL AND `playlist_data`.`object_type`='live_stream';");
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Call to method fetch_assoc from undeclared class \Ampache\Module\System\Dba
        Open

                while ($row = Dba::fetch_assoc($db_object_types)) {
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Class extends undeclared class \Ampache\Repository\Model\playlist_object
        Open

        class Playlist extends playlist_object
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->id
        Open

                $params  = array($this->id);
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Call to deprecated function \Ampache\Module\Authorization\Access::check() defined at /code/src/Module/Authorization/Access.php:154
        Open

                $is_admin = ($userOnly === false || (Access::check('interface', 100, $user_id) || $user_id == -1));
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->username
        Open

                    $this->username = User::get_username($new_user);
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Call to method write from undeclared class \Ampache\Module\System\Dba
        Open

                    Dba::write($sql, array($this->user, $this->username, $this->user));
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Call to method fetch_assoc from undeclared class \Ampache\Module\System\Dba
        Open

                while ($row = Dba::fetch_assoc($db_results)) {
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->id
        Open

                Dba::write($sql, array($this->id));
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Call to method write from undeclared class \Ampache\Module\System\Dba
        Open

                    Dba::write($sql);
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared class \Ampache\Repository\Model\playlist_object
        Open

                    if ($user_id > 0 && parent::is_cached($key, $user_id)) {
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->id
        Open

                        $params  = array($this->id, $user_id, $user_id, $user_id, $user_id);
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->user
        Open

                    Dba::write($sql, array($this->user, $this->username, $this->user));
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->id
        Open

                debug_event(self::class, 'Delete all tracks from: ' . $this->id, 5);
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Call to deprecated function \debug_event() defined at /code/src/Config/functions.php:651
        Open

                debug_event(self::class, 'Delete item_id: ' . $object_id . ' from ' . $this->id, 5);
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->id
        Open

                    debug_event(self::class, $this->id . ' has_item: ' . ($results['object_id'] ?? $results['track']), 5);
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Call to method write from undeclared class \Ampache\Module\System\Dba
        Open

                Dba::write("DELETE FROM `playlist` USING `playlist` LEFT JOIN `playlist_data` ON `playlist_data`.`playlist` = `playlist`.`id` WHERE `playlist_data`.`object_id` IS NULL;");
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Call to method read from undeclared class \Ampache\Module\System\Dba
        Open

                $db_results = Dba::read($sql);
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->name
        Open

                if (isset($data['name']) && $data['name'] != $this->name) {
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Call to method get_username from undeclared class \Ampache\Repository\Model\User
        Open

                    $this->username = User::get_username($new_user);
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->id
        Open

                $tracks = Dba::read($sql, array($this->id));
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Call to method fetch_assoc from undeclared class \Ampache\Module\System\Dba
        Open

                while ($row = Dba::fetch_assoc($db_results)) {
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Call to method count_table from undeclared class \Ampache\Repository\Model\Catalog
        Open

                Catalog::count_table('playlist');
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared class \Ampache\Repository\Model\playlist_object
        Open

                        return parent::get_from_cache($key, $user_id);
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Return type of get_items() is undeclared type \Ampache\Repository\Model\list
        Open

            public function get_items(): array
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Call to method read from undeclared class \Ampache\Module\System\Dba
        Open

                    $db_results = Dba::read($sql, $params);
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->id
        Open

                        $values[] = $this->id;
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Call to method write from undeclared class \Ampache\Module\System\Dba
        Open

                Dba::write($sql, array($this->id, $object_id));
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->id
        Open

                    $params      = array($this->id);
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->id
        Open

                debug_event(self::class, $this->id . ' set track: ' . $track . ' to ' . $object_id, 5);
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Call to method fetch_assoc from undeclared class \Ampache\Module\System\Dba
        Open

                    while ($row = Dba::fetch_assoc($db_results)) {
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Call to method fetch_assoc from undeclared class \Ampache\Module\System\Dba
        Open

                while ($row = Dba::fetch_assoc($db_results)) {
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Call to method fetch_assoc from undeclared class \Ampache\Module\System\Dba
        Open

                    while ($row = Dba::fetch_assoc($db_results)) {
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Call to method read from undeclared class \Ampache\Module\System\Dba
        Open

                $db_results = Dba::read($sql, $params);
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->id
        Open

                return (int)($this->id ?? 0);
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->last_update (Did you mean $last_update)
        Open

                    $this->last_update = $last_update;
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Call to method fetch_assoc from undeclared class \Ampache\Module\System\Dba
        Open

                while ($row = Dba::fetch_assoc($db_results)) {
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->id
        Open

                debug_event(self::class, 'Delete track: ' . $track . ' from ' . $this->id, 5);
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared class \Ampache\Repository\Model\playlist_object
        Open

                if ($user_id > 0 && parent::is_cached($key, $user_id)) {
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->id
        Open

                Dba::write($sql, array($this->id));
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Call to method fetch_assoc from undeclared class \Ampache\Module\System\Dba
        Open

                $row        = Dba::fetch_assoc($db_results);
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Call to method escape from undeclared class \Ampache\Module\System\Dba
        Open

                        $sql .= "(" . Dba::escape($data['id']) . ", " . Dba::escape($data['track']) . "), ";
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Call to deprecated function \Ampache\Module\Authorization\Access::check() defined at /code/src/Module/Authorization/Access.php:154
        Open

                if (Core::get_global('user')->id != $this->user && !Access::check('interface', 50)) {
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Call to method read from undeclared class \Ampache\Module\System\Dba
        Open

                $tracks = Dba::read($sql, array($this->id));
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->id
        Open

                debug_event(self::class, "add_medias to: " . $this->id, 5);
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Call to method count_table from undeclared class \Ampache\Repository\Model\Catalog
        Open

                Catalog::count_table('playlist');
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Call to method write from undeclared class \Ampache\Module\System\Dba
        Open

                Dba::write($sql, array($this->id, $track));
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Call to deprecated function \debug_event() defined at /code/src/Config/functions.php:651
        Open

                debug_event(self::class, 'Delete track: ' . $track . ' from ' . $this->id, 5);
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Call to method write from undeclared class \Ampache\Module\System\Dba
        Open

                return Dba::write($sql, $params);
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Call to method write from undeclared class \Ampache\Module\System\Dba
        Open

                    Dba::write("DELETE FROM `playlist_data` USING `playlist_data` LEFT JOIN `" . $object_type . "` ON `" . $object_type . "`.`id` = `playlist_data`.`object_id` WHERE `" . $object_type . "`.`file` IS NULL AND `playlist_data`.`object_type`='" . $object_type . "';");
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared class \Ampache\Repository\Model\playlist_object
        Open

                parent::format($details);
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->id
        Open

                    $params      = array($this->id);
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->id
        Open

                $params    = array($this->id);
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->last_duration
        Open

                if (isset($data['last_duration']) && $data['last_duration'] != $this->last_duration) {
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->user
        Open

                    $this->user     = $new_user;
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->username
        Open

                    Dba::write($sql, array($this->user, $this->username, $this->user));
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->name
        Open

                    $this->name = $new_name;
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->id
        Open

                return Dba::write($sql, array($value, $this->id));
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->id
        Open

                $db_results = Dba::read($sql, array($this->id));
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Call to deprecated function \debug_event() defined at /code/src/Config/functions.php:651
        Open

                        debug_event(self::class, "Can't add a duplicate " . $data['object_type'] . " (" . $data['object_id'] . ") when unique_playlist is enabled", 3);
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Call to method write from undeclared class \Ampache\Module\System\Dba
        Open

                Dba::write($sql, array($this->id, 'song', $object_id, $track));
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Call to method read from undeclared class \Ampache\Module\System\Dba
        Open

                        $db_results = Dba::read($sql, array($this->id, $object, $track));
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Call to method read from undeclared class \Ampache\Module\System\Dba
        Open

                $db_results = Dba::read($sql, array($playlist_user));
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->name
        Open

                    if ($row['name'] == $this->name) {
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Call to method write from undeclared class \Ampache\Module\System\Dba
        Open

                Dba::write($sql, array($this->id));
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->id
        Open

                Dba::write($sql, array($this->id));
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->id
        Open

                $db_results = Dba::query($sql, array($this->id));
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Call to method fetch_assoc from undeclared class \Ampache\Module\System\Dba
        Open

                while ($row = Dba::fetch_assoc($db_results)) {
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Doc-block of get_items contains declared return type \Ampache\Repository\Model\list which is incompatible with the return type array declared in the signature
        Open

             * @return list<array{
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Call to deprecated function \debug_event() defined at /code/src/Config/functions.php:651
        Open

                            debug_event(__CLASS__, "get_items(): $object_type not handled", 5);
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Call to method write from undeclared class \Ampache\Module\System\Dba
        Open

                return Dba::write($sql, array($value, $this->id));
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Call to method fetch_assoc from undeclared class \Ampache\Module\System\Dba
        Open

                while ($row = Dba::fetch_assoc($tracks)) {
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Call to deprecated function \debug_event() defined at /code/src/Config/functions.php:651
        Open

                debug_event(self::class, "add_medias to: " . $this->id, 5);
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->id
        Open

                    $this->id &&
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Call to method write from undeclared class \Ampache\Module\System\Dba
        Open

                Dba::write($sql, array($this->id));
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Call to method fetch_assoc from undeclared class \Ampache\Module\System\Dba
        Open

                    $results = Dba::fetch_assoc($db_results);
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Call to undeclared method \Ampache\Repository\Model\Playlist::get_info
        Open

                $info = $this->get_info($object_id, static::DB_TABLENAME);
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Call to deprecated function \Ampache\Module\Authorization\Access::check() defined at /code/src/Module/Authorization/Access.php:154
        Open

                $is_admin = (Access::check('interface', 100, $user_id) || $user_id == -1);
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Call to method fetch_assoc from undeclared class \Ampache\Module\System\Dba
        Open

                while ($row = Dba::fetch_assoc($db_results)) {
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->user
        Open

                if (isset($data['pl_user']) && $data['pl_user'] != $this->user) {
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->user
        Open

                if (Core::get_global('user')->id != $this->user && !Access::check('interface', 50)) {
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Call to deprecated function \debug_event() defined at /code/src/Config/functions.php:651
        Open

                    debug_event(self::class, "Added $count tracks to playlist: " . $this->id, 5);
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->id
        Open

                    debug_event(self::class, "Added $count tracks to playlist: " . $this->id, 5);
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->id
        Open

                Dba::write($sql, array($this->id, $track));
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Call to deprecated function \debug_event() defined at /code/src/Config/functions.php:651
        Open

                debug_event(self::class, $this->id . ' set track: ' . $track . ' to ' . $object_id, 5);
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared class \Ampache\Repository\Model\playlist_object
        Open

                    parent::add_to_cache('playlist', $row['id'], $row);
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Call to method escape from undeclared class \Ampache\Module\System\Dba
        Open

                        $sql .= "$join `name` NOT LIKE '" . Dba::escape($hide_string) . "%' ";
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Call to method read from undeclared class \Ampache\Module\System\Dba
        Open

                $db_object_types = Dba::read($sql);
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Call to deprecated function \debug_event() defined at /code/src/Config/functions.php:651
        Open

                            debug_event(__CLASS__, "get_items(): $object_type not handled", 5);
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Call to method fetch_assoc from undeclared class \Ampache\Module\System\Dba
        Open

                while ($row = Dba::fetch_assoc($db_object_types)) {
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Call to method read from undeclared class \Ampache\Module\System\Dba
        Open

                $db_results = Dba::read($sql);
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Call to method update_mapping from undeclared class \Ampache\Repository\Model\Catalog
        Open

                    Catalog::update_mapping('playlist');
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Call to method read from undeclared class \Ampache\Module\System\Dba
        Open

                $db_results = Dba::read($sql, array($name, $user_id, $type));
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->id
        Open

                debug_event(self::class, 'Delete object_id: ' . $object_id . ' from ' . $this->id, 5);
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Call to method fetch_assoc from undeclared class \Ampache\Module\System\Dba
        Open

                    $results    = Dba::fetch_assoc($db_results);
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Call to method read from undeclared class \Ampache\Module\System\Dba
        Open

                $db_results = Dba::read($sql, $params);
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->id
        Open

                Dba::write($sql, array($this->id));
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared class \Ampache\Repository\Model\playlist_object
        Open

                    return parent::get_from_cache($key, $user_id);
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Call to method write from undeclared class \Ampache\Module\System\Dba
        Open

                Dba::write($sql, array($index, $track_id));
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Call to method read from undeclared class \Ampache\Module\System\Dba
        Open

                $db_results = Dba::read($sql, array($this->id));
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Call to deprecated function \debug_event() defined at /code/src/Config/functions.php:651
        Open

                debug_event(self::class, 'Delete all tracks from: ' . $this->id, 5);
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Call to method fetch_assoc from undeclared class \Ampache\Module\System\Dba
        Open

                while ($row = Dba::fetch_assoc($db_results)) {
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Call to method escape from undeclared class \Ampache\Module\System\Dba
        Open

                    $sql = "UPDATE `playlist` SET `" . Dba::escape($column) . "` = " . $count . " WHERE `id` = " . Dba::escape($this->id);
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Call to method write from undeclared class \Ampache\Module\System\Dba
        Open

                Dba::write($sql, array($this->id, $object_id));
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->id
        Open

                debug_event(self::class, 'Delete item_id: ' . $object_id . ' from ' . $this->id, 5);
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->id
        Open

                        $db_results = Dba::read($sql, array($this->id, $object));
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Call to method read from undeclared class \Ampache\Module\System\Dba
        Open

                $db_object_types = Dba::read($sql);
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Call to method read from undeclared class \Ampache\Module\System\Dba
        Open

                    $db_results = Dba::read($sql, $params);
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Call to method read from undeclared class \Ampache\Module\System\Dba
        Open

                $db_results = Dba::read($sql, $params);
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Call to method fetch_assoc from undeclared class \Ampache\Module\System\Dba
        Open

                while ($row = Dba::fetch_assoc($db_results)) {
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Call to method fetch_row from undeclared class \Ampache\Module\System\Dba
        Open

                $row        = Dba::fetch_row($db_results);
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Call to method write from undeclared class \Ampache\Module\System\Dba
        Open

                    Dba::write(rtrim($sql, ', '), $values);
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Call to method write from undeclared class \Ampache\Module\System\Dba
        Open

                Dba::write($sql, array($name, $user_id, $username, $type, $date, $date));
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Call to method insert_id from undeclared class \Ampache\Module\System\Dba
        Open

                $insert_id = Dba::insert_id();
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->id
        Open

                Dba::write($sql, array($this->id, $track));
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Call to method write from undeclared class \Ampache\Module\System\Dba
        Open

                Dba::write($sql, array($this->id, $track));
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Call to method write from undeclared class \Ampache\Module\System\Dba
        Open

                Dba::write($sql, array($this->id));
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->type
        Open

                if (isset($data['pl_type']) && $data['pl_type'] != $this->type) {
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->last_count
        Open

                if (isset($data['last_count']) && $data['last_count'] != $this->last_count) {
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->type
        Open

                    $this->type = $new_type;
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Call to method fetch_assoc from undeclared class \Ampache\Module\System\Dba
        Open

                $row        = Dba::fetch_assoc($db_results);
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Call to method get_username from undeclared class \Ampache\Repository\Model\User
        Open

                $username = User::get_username($user_id);
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->id
        Open

                    $sql = "UPDATE `playlist` SET `" . Dba::escape($column) . "` = " . $count . " WHERE `id` = " . Dba::escape($this->id);
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->id
        Open

                Dba::write($sql, array($this->id, $object_id));
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Call to deprecated function \debug_event() defined at /code/src/Config/functions.php:651
        Open

                debug_event(self::class, 'Delete object_id: ' . $object_id . ' from ' . $this->id, 5);
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->id
        Open

                Dba::write($sql, array($this->id, $object_id));
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->id
        Open

                Dba::write($sql, array($this->id, 'song', $object_id, $track));
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->id
        Open

                    $db_results = Dba::read($sql, array($this->id, $track));
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Call to method read from undeclared class \Ampache\Module\System\Dba
        Open

                $db_results = Dba::read($sql, array($user_id));
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Call to method write from undeclared class \Ampache\Module\System\Dba
        Open

                Dba::write($sql, array($this->id));
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared class \Ampache\Repository\Model\playlist_object
        Open

                    parent::add_to_cache($key, $user_id, $results);
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Call to method read from undeclared class \Ampache\Module\System\Dba
        Open

                $db_results = Dba::read($sql, $params);
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Saw a token Phan may have failed to parse after '* @return list<array> after <code>list,</code> saw <code>'&lt;'</code></array>
        Open

             * @return list<array{
        Severity: Info
        Found in src/Repository/Model/Playlist.php by phan

        Call to method write from undeclared class \Ampache\Module\System\Dba
        Open

                    Dba::write($sql);
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->id
        Open

                        $db_results = Dba::read($sql, array($this->id, $object, $track));
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Call to method read from undeclared class \Ampache\Module\System\Dba
        Open

                        $db_results = Dba::read($sql, array($this->id, $object));
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Call to deprecated function \debug_event() defined at /code/src/Config/functions.php:651
        Open

                    debug_event(self::class, $this->id . ' has_item: ' . ($results['object_id'] ?? $results['track']), 5);
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->name
        Open

                    if ($row['name'] == $this->name) {
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Reference to undeclared property \Ampache\Repository\Model\Playlist->id
        Open

                return $this->id;
        Severity: Minor
        Found in src/Repository/Model/Playlist.php by phan

        Call to method read from undeclared class \Ampache\Module\System\Dba
        Open

                    $db_results = Dba::read($sql, array($this->id, $track));
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

        Call to method query from undeclared class \Ampache\Module\System\Dba
        Open

                $db_results = Dba::query($sql, array($this->id));
        Severity: Critical
        Found in src/Repository/Model/Playlist.php by phan

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

            public static function build_cache($ids): bool
            {
                if (empty($ids)) {
                    return false;
                }
        Severity: Major
        Found in src/Repository/Model/Playlist.php and 3 other locations - About 1 hr to fix
        src/Repository/Model/Tag.php on lines 104..118
        src/Repository/Model/Useractivity.php on lines 70..85
        src/Repository/Model/Video.php on lines 208..223

        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 111.

        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 $user_id is not named in camelCase.
        Open

            public static function check($name, $type, $user_id = null): int
            {
                if ($user_id === null) {
                    $user    = Core::get_global('user');
                    $user_id = $user->id ?? -1;
        Severity: Minor
        Found in src/Repository/Model/Playlist.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 function delete_track($object_id): bool
            {
                $sql = "DELETE FROM `playlist_data` WHERE `playlist_data`.`playlist` = ? AND `playlist_data`.`id` = ? LIMIT 1";
                Dba::write($sql, array($this->id, $object_id));
                debug_event(self::class, 'Delete item_id: ' . $object_id . ' from ' . $this->id, 5);
        Severity: Minor
        Found in src/Repository/Model/Playlist.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_name is not named in camelCase.
        Open

            private function _update_name($new_name): void
            {
                if ($this->_update_item('name', $new_name)) {
                    $this->name = $new_name;
                }
        Severity: Minor
        Found in src/Repository/Model/Playlist.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_playlist_array($user_id = 0): array
            {
                if ($user_id === 0) {
                    $user    = Core::get_global('user');
                    $user_id = $user->id ?? 0;
        Severity: Minor
        Found in src/Repository/Model/Playlist.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_type is not named in camelCase.
        Open

            private function _update_type($new_type): void
            {
                if ($this->_update_item('type', $new_type)) {
                    $this->type = $new_type;
                }
        Severity: Minor
        Found in src/Repository/Model/Playlist.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 create($name, $type, $user_id = null, $existing = true): ?int
            {
                if ($user_id === null) {
                    $user    = Core::get_global('user');
                    $user_id = $user->id ?? -1;
        Severity: Minor
        Found in src/Repository/Model/Playlist.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 $playlist_user is not named in camelCase.
        Open

            public function has_search($playlist_user): int
            {
                // search for your own playlist
                $sql        = "SELECT `id`, `name` FROM `search` WHERE `user` = ?";
                $db_results = Dba::read($sql, array($playlist_user));
        Severity: Minor
        Found in src/Repository/Model/Playlist.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 $playlist_name is not named in camelCase.
        Open

            public static function get_playlists($user_id = null, $playlist_name = '', $like = true, $includePublic = true, $includeHidden = true, $userOnly = false): array
            {
                if (!$user_id) {
                    $user    = Core::get_global('user');
                    $user_id = $user->id ?? 0;
        Severity: Minor
        Found in src/Repository/Model/Playlist.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 function delete_song($object_id): bool
            {
                $sql = "DELETE FROM `playlist_data` WHERE `playlist_data`.`playlist` = ? AND `playlist_data`.`object_id` = ? LIMIT 1";
                Dba::write($sql, array($this->id, $object_id));
                debug_event(self::class, 'Delete object_id: ' . $object_id . ' from ' . $this->id, 5);
        Severity: Minor
        Found in src/Repository/Model/Playlist.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 $track_id is not named in camelCase.
        Open

            public function update_track_number($track_id, $index): void
            {
                $sql = "UPDATE `playlist_data` SET `track` = ? WHERE `id` = ?";
                Dba::write($sql, array($index, $track_id));
            }
        Severity: Minor
        Found in src/Repository/Model/Playlist.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 function set_by_track_number($object_id, $track): bool
            {
                if (AmpConfig::get('unique_playlist') && $this->has_item($object_id, $track)) {
                    return false;
                }
        Severity: Minor
        Found in src/Repository/Model/Playlist.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)
            {
                $sql    = "UPDATE `playlist_data` SET `object_id` = ? WHERE `object_id` = ? AND `object_type` = ?;";
                $params = array($new_object_id, $old_object_id, $object_type);
        
        
        Severity: Minor
        Found in src/Repository/Model/Playlist.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)
            {
                $sql    = "UPDATE `playlist_data` SET `object_id` = ? WHERE `object_id` = ? AND `object_type` = ?;";
                $params = array($new_object_id, $old_object_id, $object_type);
        
        
        Severity: Minor
        Found in src/Repository/Model/Playlist.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)
            {
                $sql    = "UPDATE `playlist_data` SET `object_id` = ? WHERE `object_id` = ? AND `object_type` = ?;";
                $params = array($new_object_id, $old_object_id, $object_type);
        
        
        Severity: Minor
        Found in src/Repository/Model/Playlist.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 function __construct($object_id = 0)
            {
                if (!$object_id) {
                    return;
                }
        Severity: Minor
        Found in src/Repository/Model/Playlist.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 $song_ids is not named in camelCase.
        Open

            public function add_songs($song_ids = array()): bool
            {
                $medias = array();
                foreach ($song_ids as $song_id) {
                    $medias[] = array(
        Severity: Minor
        Found in src/Repository/Model/Playlist.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_playlists($user_id = null, $playlist_name = '', $like = true, $includePublic = true, $includeHidden = true, $userOnly = false): array
            {
                if (!$user_id) {
                    $user    = Core::get_global('user');
                    $user_id = $user->id ?? 0;
        Severity: Minor
        Found in src/Repository/Model/Playlist.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_user is not named in camelCase.
        Open

            private function _update_user($new_user): void
            {
                if ($this->_update_item('user', $new_user)) {
                    $this->user     = $new_user;
                    $this->username = User::get_username($new_user);
        Severity: Minor
        Found in src/Repository/Model/Playlist.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

        Method name "_set_last" should not be prefixed with an underscore to indicate visibility
        Open

            private function _set_last($count, $column): void

        Method name "_update_last" should not be prefixed with an underscore to indicate visibility
        Open

            private function _update_last(): void

        Method name "_update_item" should not be prefixed with an underscore to indicate visibility
        Open

            private function _update_item($field, $value)

        Method name "_update_user" should not be prefixed with an underscore to indicate visibility
        Open

            private function _update_user($new_user): void

        Method name "_update_name" should not be prefixed with an underscore to indicate visibility
        Open

            private function _update_name($new_name): void

        Method name "_update_type" should not be prefixed with an underscore to indicate visibility
        Open

            private function _update_type($new_type): void

        Expected 0 spaces after opening bracket; newline found
        Open

                if (

        There are no issues that match your filters.

        Category
        Status