ampache/ampache

View on GitHub
src/Module/Application/Playback/Play2Action.php

Summary

Maintainability
F
1 mo
Test Coverage

run accesses the super-global variable $_SERVER.
Open

    public function run(ServerRequestInterface $request, GuiGatekeeperInterface $gatekeeper): ?ResponseInterface
    {
        //$this->logger->debug(print_r(apache_request_headers(), true), [LegacyLogger::CONTEXT_TYPE => __CLASS__]);
        ob_end_clean();

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

run accesses the super-global variable $_COOKIE.
Open

    public function run(ServerRequestInterface $request, GuiGatekeeperInterface $gatekeeper): ?ResponseInterface
    {
        //$this->logger->debug(print_r(apache_request_headers(), true), [LegacyLogger::CONTEXT_TYPE => __CLASS__]);
        ob_end_clean();

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

run accesses the super-global variable $_SESSION.
Open

    public function run(ServerRequestInterface $request, GuiGatekeeperInterface $gatekeeper): ?ResponseInterface
    {
        //$this->logger->debug(print_r(apache_request_headers(), true), [LegacyLogger::CONTEXT_TYPE => __CLASS__]);
        ob_end_clean();

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

run accesses the super-global variable $_REQUEST.
Open

    public function run(ServerRequestInterface $request, GuiGatekeeperInterface $gatekeeper): ?ResponseInterface
    {
        //$this->logger->debug(print_r(apache_request_headers(), true), [LegacyLogger::CONTEXT_TYPE => __CLASS__]);
        ob_end_clean();

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

run accesses the super-global variable $_REQUEST.
Open

    public function run(ServerRequestInterface $request, GuiGatekeeperInterface $gatekeeper): ?ResponseInterface
    {
        //$this->logger->debug(print_r(apache_request_headers(), true), [LegacyLogger::CONTEXT_TYPE => __CLASS__]);
        ob_end_clean();

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

run accesses the super-global variable $_REQUEST.
Open

    public function run(ServerRequestInterface $request, GuiGatekeeperInterface $gatekeeper): ?ResponseInterface
    {
        //$this->logger->debug(print_r(apache_request_headers(), true), [LegacyLogger::CONTEXT_TYPE => __CLASS__]);
        ob_end_clean();

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

run accesses the super-global variable $_COOKIE.
Open

    public function run(ServerRequestInterface $request, GuiGatekeeperInterface $gatekeeper): ?ResponseInterface
    {
        //$this->logger->debug(print_r(apache_request_headers(), true), [LegacyLogger::CONTEXT_TYPE => __CLASS__]);
        ob_end_clean();

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

run accesses the super-global variable $_REQUEST.
Open

    public function run(ServerRequestInterface $request, GuiGatekeeperInterface $gatekeeper): ?ResponseInterface
    {
        //$this->logger->debug(print_r(apache_request_headers(), true), [LegacyLogger::CONTEXT_TYPE => __CLASS__]);
        ob_end_clean();

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

run accesses the super-global variable $_SESSION.
Open

    public function run(ServerRequestInterface $request, GuiGatekeeperInterface $gatekeeper): ?ResponseInterface
    {
        //$this->logger->debug(print_r(apache_request_headers(), true), [LegacyLogger::CONTEXT_TYPE => __CLASS__]);
        ob_end_clean();

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

run accesses the super-global variable $_REQUEST.
Open

    public function run(ServerRequestInterface $request, GuiGatekeeperInterface $gatekeeper): ?ResponseInterface
    {
        //$this->logger->debug(print_r(apache_request_headers(), true), [LegacyLogger::CONTEXT_TYPE => __CLASS__]);
        ob_end_clean();

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

run accesses the super-global variable $_SERVER.
Open

    public function run(ServerRequestInterface $request, GuiGatekeeperInterface $gatekeeper): ?ResponseInterface
    {
        //$this->logger->debug(print_r(apache_request_headers(), true), [LegacyLogger::CONTEXT_TYPE => __CLASS__]);
        ob_end_clean();

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

run accesses the super-global variable $_SESSION.
Open

    public function run(ServerRequestInterface $request, GuiGatekeeperInterface $gatekeeper): ?ResponseInterface
    {
        //$this->logger->debug(print_r(apache_request_headers(), true), [LegacyLogger::CONTEXT_TYPE => __CLASS__]);
        ob_end_clean();

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

run accesses the super-global variable $_COOKIE.
Open

    public function run(ServerRequestInterface $request, GuiGatekeeperInterface $gatekeeper): ?ResponseInterface
    {
        //$this->logger->debug(print_r(apache_request_headers(), true), [LegacyLogger::CONTEXT_TYPE => __CLASS__]);
        ob_end_clean();

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

run accesses the super-global variable $_SERVER.
Open

    public function run(ServerRequestInterface $request, GuiGatekeeperInterface $gatekeeper): ?ResponseInterface
    {
        //$this->logger->debug(print_r(apache_request_headers(), true), [LegacyLogger::CONTEXT_TYPE => __CLASS__]);
        ob_end_clean();

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

run accesses the super-global variable $_SESSION.
Open

    public function run(ServerRequestInterface $request, GuiGatekeeperInterface $gatekeeper): ?ResponseInterface
    {
        //$this->logger->debug(print_r(apache_request_headers(), true), [LegacyLogger::CONTEXT_TYPE => __CLASS__]);
        ob_end_clean();

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

run accesses the super-global variable $_REQUEST.
Open

    public function run(ServerRequestInterface $request, GuiGatekeeperInterface $gatekeeper): ?ResponseInterface
    {
        //$this->logger->debug(print_r(apache_request_headers(), true), [LegacyLogger::CONTEXT_TYPE => __CLASS__]);
        ob_end_clean();

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

Function run has a Cognitive Complexity of 295 (exceeds 5 allowed). Consider refactoring.
Open

    public function run(ServerRequestInterface $request, GuiGatekeeperInterface $gatekeeper): ?ResponseInterface
    {
        //$this->logger->debug(print_r(apache_request_headers(), true), [LegacyLogger::CONTEXT_TYPE => __CLASS__]);
        ob_end_clean();

Severity: Minor
Found in src/Module/Application/Playback/Play2Action.php - About 6 days 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 run has 848 lines of code (exceeds 200 allowed). Consider refactoring.
Open

    public function run(ServerRequestInterface $request, GuiGatekeeperInterface $gatekeeper): ?ResponseInterface
    {
        //$this->logger->debug(print_r(apache_request_headers(), true), [LegacyLogger::CONTEXT_TYPE => __CLASS__]);
        ob_end_clean();

Severity: Major
Found in src/Module/Application/Playback/Play2Action.php - About 3 days to fix

    File Play2Action.php has 914 lines of code (exceeds 500 allowed). Consider refactoring.
    Open

    <?php
    
    declare(strict_types=0);
    
    /**
    Severity: Major
    Found in src/Module/Application/Playback/Play2Action.php - About 1 day to fix

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

      final class Play2Action implements ApplicationActionInterface
      {
          public const REQUEST_KEY = 'play2';
      
          private RequestParserInterface $requestParser;

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

              RequestParserInterface $requestParser,
              Horde_Browser $browser,
              AuthenticationManagerInterface $authenticationManager,
              NetworkCheckerInterface $networkChecker,
              UserRepositoryInterface $userRepository,
      Severity: Major
      Found in src/Module/Application/Playback/Play2Action.php - About 50 mins to fix

        Consider simplifying this complex logical expression.
        Open

                    if (
                        $transcode_cfg != 'never' &&
                        $transcode_to &&
                        ($bitrate === 0 || $bitrate = (int)AmpConfig::get('transcode_bitrate', 128) * 1000) &&
                        ($file_target !== null && is_file($file_target))
        Severity: Major
        Found in src/Module/Application/Playback/Play2Action.php - About 40 mins to fix

          Avoid too many return statements within this method.
          Open

                      return null;
          Severity: Major
          Found in src/Module/Application/Playback/Play2Action.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                                return null;
            Severity: Major
            Found in src/Module/Application/Playback/Play2Action.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                              return null;
              Severity: Major
              Found in src/Module/Application/Playback/Play2Action.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return null;
                Severity: Major
                Found in src/Module/Application/Playback/Play2Action.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return null;
                  Severity: Major
                  Found in src/Module/Application/Playback/Play2Action.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                return null;
                    Severity: Major
                    Found in src/Module/Application/Playback/Play2Action.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                      return null;
                      Severity: Major
                      Found in src/Module/Application/Playback/Play2Action.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                            return null;
                        Severity: Major
                        Found in src/Module/Application/Playback/Play2Action.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                      return null;
                          Severity: Major
                          Found in src/Module/Application/Playback/Play2Action.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                        return null;
                            Severity: Major
                            Found in src/Module/Application/Playback/Play2Action.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                                  return null;
                              Severity: Major
                              Found in src/Module/Application/Playback/Play2Action.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                                return null;
                                Severity: Major
                                Found in src/Module/Application/Playback/Play2Action.php - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                                      return null;
                                  Severity: Major
                                  Found in src/Module/Application/Playback/Play2Action.php - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                            return null;
                                    Severity: Major
                                    Found in src/Module/Application/Playback/Play2Action.php - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                                      return null;
                                      Severity: Major
                                      Found in src/Module/Application/Playback/Play2Action.php - About 30 mins to fix

                                        Avoid too many return statements within this method.
                                        Open

                                                    return null;
                                        Severity: Major
                                        Found in src/Module/Application/Playback/Play2Action.php - About 30 mins to fix

                                          Avoid too many return statements within this method.
                                          Open

                                                              return null;
                                          Severity: Major
                                          Found in src/Module/Application/Playback/Play2Action.php - About 30 mins to fix

                                            Avoid too many return statements within this method.
                                            Open

                                                        return null;
                                            Severity: Major
                                            Found in src/Module/Application/Playback/Play2Action.php - About 30 mins to fix

                                              Avoid too many return statements within this method.
                                              Open

                                                                  return null;
                                              Severity: Major
                                              Found in src/Module/Application/Playback/Play2Action.php - About 30 mins to fix

                                                Avoid too many return statements within this method.
                                                Open

                                                            return null;
                                                Severity: Major
                                                Found in src/Module/Application/Playback/Play2Action.php - About 30 mins to fix

                                                  Avoid too many return statements within this method.
                                                  Open

                                                              return null;
                                                  Severity: Major
                                                  Found in src/Module/Application/Playback/Play2Action.php - About 30 mins to fix

                                                    Avoid too many return statements within this method.
                                                    Open

                                                                    return null;
                                                    Severity: Major
                                                    Found in src/Module/Application/Playback/Play2Action.php - About 30 mins to fix

                                                      Avoid too many return statements within this method.
                                                      Open

                                                                  return null;
                                                      Severity: Major
                                                      Found in src/Module/Application/Playback/Play2Action.php - About 30 mins to fix

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

                                                        final class Play2Action implements ApplicationActionInterface
                                                        {
                                                            public const REQUEST_KEY = 'play2';
                                                        
                                                            private RequestParserInterface $requestParser;

                                                        The method run() has an NPath complexity of 9223372036854775807. The configured NPath complexity threshold is 200.
                                                        Open

                                                            public function run(ServerRequestInterface $request, GuiGatekeeperInterface $gatekeeper): ?ResponseInterface
                                                            {
                                                                //$this->logger->debug(print_r(apache_request_headers(), true), [LegacyLogger::CONTEXT_TYPE => __CLASS__]);
                                                                ob_end_clean();
                                                        
                                                        

                                                        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 run() has 1089 lines of code. Current threshold is set to 100. Avoid really long methods.
                                                        Open

                                                            public function run(ServerRequestInterface $request, GuiGatekeeperInterface $gatekeeper): ?ResponseInterface
                                                            {
                                                                //$this->logger->debug(print_r(apache_request_headers(), true), [LegacyLogger::CONTEXT_TYPE => __CLASS__]);
                                                                ob_end_clean();
                                                        
                                                        

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

                                                            public function run(ServerRequestInterface $request, GuiGatekeeperInterface $gatekeeper): ?ResponseInterface
                                                            {
                                                                //$this->logger->debug(print_r(apache_request_headers(), true), [LegacyLogger::CONTEXT_TYPE => __CLASS__]);
                                                                ob_end_clean();
                                                        
                                                        

                                                        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 class Play2Action has a coupling between objects value of 31. Consider to reduce the number of dependencies under 13.
                                                        Open

                                                        final class Play2Action implements ApplicationActionInterface
                                                        {
                                                            public const REQUEST_KEY = 'play2';
                                                        
                                                            private RequestParserInterface $requestParser;

                                                        CouplingBetweenObjects

                                                        Since: 1.1.0

                                                        A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

                                                        Example

                                                        class Foo {
                                                            /**
                                                             * @var \foo\bar\X
                                                             */
                                                            private $x = null;
                                                        
                                                            /**
                                                             * @var \foo\bar\Y
                                                             */
                                                            private $y = null;
                                                        
                                                            /**
                                                             * @var \foo\bar\Z
                                                             */
                                                            private $z = null;
                                                        
                                                            public function setFoo(\Foo $foo) {}
                                                            public function setBar(\Bar $bar) {}
                                                            public function setBaz(\Baz $baz) {}
                                                        
                                                            /**
                                                             * @return \SplObjectStorage
                                                             * @throws \OutOfRangeException
                                                             * @throws \InvalidArgumentException
                                                             * @throws \ErrorException
                                                             */
                                                            public function process(\Iterator $it) {}
                                                        
                                                            // ...
                                                        }

                                                        Source https://phpmd.org/rules/design.html#couplingbetweenobjects

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

                                                                        } else {
                                                                            $rtype = $type;
                                                                        }

                                                        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 run uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                                        Open

                                                                    } else {
                                                                        $this->logger->debug(
                                                                            'Content-Range header received, skipping ' . $start . ' bytes out of ' . $streamConfiguration['file_size'],
                                                                            [LegacyLogger::CONTEXT_TYPE => __CLASS__]
                                                                        );

                                                        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 run uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                                        Open

                                                                } else {
                                                                    // default to song
                                                                    $media = new Song((int) $object_id);
                                                                }

                                                        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 run uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                                        Open

                                                                    } else {
                                                                        header('Location: ' . $media->file, true, 303);
                                                                    }

                                                        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 run uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                                        Open

                                                                    } else {
                                                                        if (!$is_download && $record_stats) {
                                                                            Stream::insert_now_playing((int) $media->id, $user_id, (int) $media->time, $session_id, ObjectTypeToClassNameMapper::reverseMap(get_class($media)));
                                                                        }
                                                                        if (Core::get_server('REQUEST_METHOD') != 'HEAD') {

                                                        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 run uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                                        Open

                                                                    } else {
                                                                        $filepointer = fopen(Core::conv_lc_file($stream_file), 'rb');
                                                                    }

                                                        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 run uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                                        Open

                                                                        } else {
                                                                            // key value
                                                                            $value = $v;
                                                                            $i     = 0;
                                                                            // set it now that you've set both

                                                        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 run uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                                        Open

                                                                } else {
                                                                    $stream_size = $streamConfiguration['file_size'];
                                                                }

                                                        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 run uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                                        Open

                                                                    } else {
                                                                        // Build up the catalog for our current object
                                                                        $catalog = Catalog::create_from_id($mediaCatalogId);
                                                                        if ($catalog === null) {
                                                                            return null;

                                                        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 run uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                                        Open

                                                                } else {
                                                                    if ($cpaction && $media instanceof Song) {
                                                                        $transcoder  = $media->run_custom_play_action($cpaction, $transcode_to ?? '');
                                                                        $filepointer = $transcoder['handle'] ?? null;
                                                                        $transcode   = true;

                                                        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 run uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                                        Open

                                                                    } else {
                                                                        // get a new random object and redirect to that object
                                                                        if (array_key_exists('random_type', $_REQUEST)) {
                                                                            $rtype = $this->requestParser->getFromRequest('random_type');
                                                                        } else {

                                                        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 run uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                                        Open

                                                                        } else {
                                                                            Stats::insert($type, $media->id, $user_id, 'share.php', array(), 'download', $time);
                                                                        }

                                                        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 run uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                                        Open

                                                                        } else {
                                                                            $this->logger->debug(
                                                                                'Transcode disabled in user settings.',
                                                                                [LegacyLogger::CONTEXT_TYPE => __CLASS__]
                                                                            );

                                                        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 run uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                                        Open

                                                                } else {
                                                                    /* These parameters had better come in on the url. */
                                                                    $action       = (string)filter_input(INPUT_GET, 'action', FILTER_SANITIZE_SPECIAL_CHARS);
                                                                    $stream_name  = (string)filter_input(INPUT_GET, 'name', FILTER_SANITIZE_SPECIAL_CHARS);
                                                                    $object_id    = (int)filter_input(INPUT_GET, 'oid', FILTER_SANITIZE_NUMBER_INT);

                                                        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 run uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                                        Open

                                                                    } else {
                                                                        // Pull history
                                                                        $song_cool_check = 0;
                                                                        $object_id       = $democratic->get_next_object($song_cool_check);
                                                                        $object_ids      = $democratic->get_cool_songs();

                                                        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 run uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                                        Open

                                                                    } else {
                                                                        fpassthru($filepointer);
                                                                    }

                                                        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 run uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                                        Open

                                                                    } else {
                                                                        $maxbitrate = (empty($transcode_settings))
                                                                            ? $media->bitrate / 1024
                                                                            : Stream::get_max_bitrate($media, $transcode_settings);
                                                                    }

                                                        ElseExpression

                                                        Since: 1.4.0

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

                                                        Example

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

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

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

                                                            public function run(ServerRequestInterface $request, GuiGatekeeperInterface $gatekeeper): ?ResponseInterface
                                                            {
                                                                //$this->logger->debug(print_r(apache_request_headers(), true), [LegacyLogger::CONTEXT_TYPE => __CLASS__]);
                                                                ob_end_clean();
                                                        
                                                        

                                                        IfStatementAssignment

                                                        Since: 2.7.0

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

                                                        Example

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

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

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

                                                                        } else {
                                                                            /** @var Song|Video $media */
                                                                            $media_bitrate = floor($media->bitrate / 1024);
                                                                            //$this->logger->debug("requested bitrate $bitrate <=> $media_bitrate ({$media->bitrate}) media bitrate", [LegacyLogger::CONTEXT_TYPE => __CLASS__]);
                                                                            if (($bitrate > 0 && $bitrate < $media_bitrate) || ($maxbitrate > 0 && $maxbitrate < $media_bitrate)) {

                                                        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 run uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                                        Open

                                                                } else {
                                                                    // No catalog, must be song preview or something like that => just redirect to file
                                                                    if ($type == "song_preview" && $media instanceof Song_Preview) {
                                                                        $media->stream(); // header redirect using preview plugin ($plugin->_plugin->stream_song_preview())
                                                                    } else {

                                                        ElseExpression

                                                        Since: 1.4.0

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

                                                        Example

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

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

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

                                                            public function run(ServerRequestInterface $request, GuiGatekeeperInterface $gatekeeper): ?ResponseInterface
                                                            {
                                                                //$this->logger->debug(print_r(apache_request_headers(), true), [LegacyLogger::CONTEXT_TYPE => __CLASS__]);
                                                                ob_end_clean();
                                                        
                                                        

                                                        IfStatementAssignment

                                                        Since: 2.7.0

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

                                                        Example

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

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

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

                                                                        } else {
                                                                            Session::update_agent($session_id, $agent);
                                                                            Session::extend($session_id, 'stream');
                                                                        }

                                                        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 run uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                                        Open

                                                                } else {
                                                                    $user_id = 0;
                                                                    $share   = new Share($share_id);
                                                        
                                                                    if (!$share->is_valid($secret, 'stream')) {

                                                        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 run uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                                        Open

                                                                    } else {
                                                                        if ($transcode_cfg != 'never') {
                                                                            $this->logger->notice(
                                                                                'Transcoding is not enforced for ' . $streamConfiguration['file_type'],
                                                                                [LegacyLogger::CONTEXT_TYPE => __CLASS__]

                                                        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 run uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                                        Open

                                                                    } else {
                                                                        $this->logger->debug(
                                                                            'Bad media duration / Max bitrate. Content-length calculation skipped.',
                                                                            [LegacyLogger::CONTEXT_TYPE => __CLASS__]
                                                                        );

                                                        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 run uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                                        Open

                                                                    } else {
                                                                        $end = $streamConfiguration['file_size'] - 1;
                                                                    }

                                                        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 run uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                                        Open

                                                                                } else {
                                                                                    Stats::insert($type, $media->id, $user_id, 'share.php', array(), 'download', $time);
                                                                                }

                                                        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 run uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                                        Open

                                                                } else {
                                                                    // output file might not be the same type
                                                                    $mime = ($type === 'video')
                                                                        ? Video::type_to_mime($streamConfiguration['file_type'])
                                                                        : Song::type_to_mime($streamConfiguration['file_type']);

                                                        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 run uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                                        Open

                                                                } else {
                                                                    header('Accept-Ranges: bytes');
                                                                }

                                                        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 run uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                                        Open

                                                                            } else {
                                                                                echo $buf;
                                                                                ob_flush();
                                                                                flush();
                                                                            }

                                                        ElseExpression

                                                        Since: 1.4.0

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

                                                        Example

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

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

                                                        Avoid unused parameters such as '$request'.
                                                        Open

                                                            public function run(ServerRequestInterface $request, GuiGatekeeperInterface $gatekeeper): ?ResponseInterface

                                                        UnusedFormalParameter

                                                        Since: 0.2

                                                        Avoid passing parameters to methods or constructors and then not using those parameters.

                                                        Example

                                                        class Foo
                                                        {
                                                            private function bar($howdy)
                                                            {
                                                                // $howdy is not used
                                                            }
                                                        }

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

                                                        Avoid unused parameters such as '$gatekeeper'.
                                                        Open

                                                            public function run(ServerRequestInterface $request, GuiGatekeeperInterface $gatekeeper): ?ResponseInterface

                                                        UnusedFormalParameter

                                                        Since: 0.2

                                                        Avoid passing parameters to methods or constructors and then not using those parameters.

                                                        Example

                                                        class Foo
                                                        {
                                                            private function bar($howdy)
                                                            {
                                                                // $howdy is not used
                                                            }
                                                        }

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

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

                                                            private RequestParserInterface $requestParser;

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

                                                                if ($slashcount > 2) {
                                                                    // e.g. ssid/3ca112fff23376ef7c74f018497dd39d/type/song/oid/280/uid/player/api/name/Glad.mp3
                                                                    $new_arr     = explode('/', $_SERVER['QUERY_STRING']);
                                                                    $new_request = array();
                                                                    $key         = null;
                                                        Severity: Major
                                                        Found in src/Module/Application/Playback/Play2Action.php and 1 other location - About 2 days to fix
                                                        src/Module/Application/Playback/PlayAction.php on lines 118..190

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

                                                        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

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

                                                                if (!$share_id) {
                                                                    // No explicit authentication, use session
                                                                    if (!$user instanceof User) {
                                                                        $user = new User($user_id);
                                                                    }
                                                        Severity: Major
                                                        Found in src/Module/Application/Playback/Play2Action.php and 1 other location - About 2 days to fix
                                                        src/Module/Application/Playback/PlayAction.php on lines 351..411

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

                                                        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

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

                                                                if (!$cpaction && !$original && !$cache_file) {
                                                                    $valid_types = $media->get_stream_types($player);
                                                                    if ($transcode_cfg != 'never' && in_array('transcode', $valid_types) && $type !== 'podcast_episode') {
                                                                        if ($transcode_to) {
                                                                            $transcode = true;
                                                        Severity: Major
                                                        Found in src/Module/Application/Playback/Play2Action.php and 1 other location - About 1 day to fix
                                                        src/Module/Application/Playback/PlayAction.php on lines 812..864

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

                                                        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

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

                                                                if (empty($this->requestParser->getFromRequest('segment'))) {
                                                                    if ($media->time) {
                                                                        header('X-Content-Duration: ' . $media->time);
                                                                    }
                                                        
                                                        
                                                        Severity: Major
                                                        Found in src/Module/Application/Playback/Play2Action.php and 1 other location - About 1 day to fix
                                                        src/Module/Application/Playback/PlayAction.php on lines 1003..1046

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

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

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

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

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

                                                        Refactorings

                                                        Further Reading

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

                                                                if ($demo_id > 0) {
                                                                    $democratic = new Democratic($demo_id);
                                                                    $democratic->set_parent();
                                                        
                                                                    // If there is a cooldown we need to make sure this song isn't a repeat
                                                        Severity: Major
                                                        Found in src/Module/Application/Playback/Play2Action.php and 1 other location - About 1 day to fix
                                                        src/Module/Application/Playback/PlayAction.php on lines 467..516

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

                                                        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

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

                                                                    if (
                                                                        $transcode_cfg != 'never' &&
                                                                        $transcode_to &&
                                                                        ($bitrate === 0 || $bitrate = (int)AmpConfig::get('transcode_bitrate', 128) * 1000) &&
                                                                        ($file_target !== null && is_file($file_target))
                                                        Severity: Major
                                                        Found in src/Module/Application/Playback/Play2Action.php and 1 other location - About 1 day to fix
                                                        src/Module/Application/Playback/PlayAction.php on lines 631..678

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

                                                        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

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

                                                                if (!empty($session_id)) {
                                                                    $user = $this->userRepository->findByStreamToken(trim($session_id));
                                                                    if ($user) {
                                                                        $user_auth = true;
                                                                        $agent     = (!empty($client))
                                                        Severity: Major
                                                        Found in src/Module/Application/Playback/Play2Action.php and 1 other location - About 1 day to fix
                                                        src/Module/Application/Playback/PlayAction.php on lines 297..331

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

                                                        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

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

                                                                if (!$transcode && $range_values > 0 && ($start > 0 || $end > 0)) {
                                                                    // Calculate stream size from byte range
                                                                    if ($range_values >= 2) {
                                                                        $end = (int)min($end, $streamConfiguration['file_size'] - 1);
                                                                    } else {
                                                        Severity: Major
                                                        Found in src/Module/Application/Playback/Play2Action.php and 1 other location - About 7 hrs to fix
                                                        src/Module/Application/Playback/PlayAction.php on lines 976..1001

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

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

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

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

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

                                                        Refactorings

                                                        Further Reading

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

                                                                if ($status === false) {
                                                                    $this->logger->error(
                                                                        'stream_select failed.',
                                                                        [LegacyLogger::CONTEXT_TYPE => __CLASS__]
                                                                    );
                                                        Severity: Major
                                                        Found in src/Module/Application/Playback/Play2Action.php and 1 other location - About 7 hrs to fix
                                                        src/Module/Application/Playback/PlayAction.php on lines 1099..1131

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

                                                        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

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

                                                                    if ($media->id > 0) {
                                                                        // If the media is disabled
                                                                        if ((isset($media->enabled) && !make_bool($media->enabled)) || !Core::is_readable(Core::conv_lc_file((string)$media->file))) {
                                                                            $this->logger->warning(
                                                                                "Error: " . $media->file . " is currently disabled, song skipped",
                                                        Severity: Major
                                                        Found in src/Module/Application/Playback/Play2Action.php and 1 other location - About 6 hrs to fix
                                                        src/Module/Application/Playback/PlayAction.php on lines 541..560

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

                                                        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

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

                                                                if ($player_customize && !$original) {
                                                                    // Trick to avoid LimitInternalRecursion reconfiguration
                                                                    $vsettings = scrub_in((string) filter_input(INPUT_GET, 'transcode_to', FILTER_SANITIZE_SPECIAL_CHARS));
                                                                    if (!empty($vsettings)) {
                                                                        $vparts  = explode('-', $vsettings);
                                                        Severity: Major
                                                        Found in src/Module/Application/Playback/Play2Action.php and 1 other location - About 4 hrs to fix
                                                        src/Module/Application/Playback/PlayAction.php on lines 234..254

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

                                                        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

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

                                                                    if (Core::get_server('REQUEST_METHOD') != 'HEAD') {
                                                                        if (!$share_id) {
                                                                            $this->logger->debug(
                                                                                'Registering download stats for {' . $media->get_stream_name() . '}...',
                                                                                [LegacyLogger::CONTEXT_TYPE => __CLASS__]
                                                        Severity: Major
                                                        Found in src/Module/Application/Playback/Play2Action.php and 1 other location - About 2 hrs to fix
                                                        src/Module/Application/Playback/PlayAction.php on lines 748..758

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

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

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

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

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

                                                        Refactorings

                                                        Further Reading

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

                                                            public function __construct(
                                                                RequestParserInterface $requestParser,
                                                                Horde_Browser $browser,
                                                                AuthenticationManagerInterface $authenticationManager,
                                                                NetworkCheckerInterface $networkChecker,
                                                        Severity: Major
                                                        Found in src/Module/Application/Playback/Play2Action.php and 7 other locations - About 1 hr to fix
                                                        src/Gui/Album/AlbumViewAdapter.php on lines 63..79
                                                        src/Gui/AlbumDisk/AlbumDiskViewAdapter.php on lines 63..79
                                                        src/Module/Api/ApiHandler.php on lines 71..87
                                                        src/Module/Application/Image/ShowAction.php on lines 71..87
                                                        src/Module/Application/Playback/PlayAction.php on lines 79..95
                                                        src/Module/Application/Share/CreateAction.php on lines 68..84
                                                        src/Module/Application/Stats/ShowUserAction.php on lines 59..75

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

                                                        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

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

                                                                if (!($user instanceof User) && array_key_exists($session_name, $_COOKIE) && Session::exists('interface', $_COOKIE[$session_name])) {
                                                                    Session::check();
                                                                    $user = (array_key_exists('userdata', $_SESSION) && array_key_exists('username', $_SESSION['userdata']))
                                                                        ? User::get_from_username($_SESSION['userdata']['username'])
                                                                        : new User(-1);
                                                        Severity: Major
                                                        Found in src/Module/Application/Playback/Play2Action.php and 1 other location - About 1 hr to fix
                                                        src/Module/Application/Playback/PlayAction.php on lines 339..344

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

                                                        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

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

                                                                    if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
                                                                        // This to avoid hang, see http://php.net/manual/en/function.proc-open.php#89338
                                                                        $transcode_error = fread($transcoder['stderr'], 4096);
                                                                        if (!empty($transcode_error)) {
                                                                            $this->logger->error(
                                                        Severity: Major
                                                        Found in src/Module/Application/Playback/Play2Action.php and 1 other location - About 1 hr to fix
                                                        src/Module/Application/Playback/PlayAction.php on lines 1061..1071

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

                                                        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

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

                                                                if (AmpConfig::get('access_control')) {
                                                                    if (
                                                                        !$this->networkChecker->check(AccessLevelEnum::TYPE_STREAM, Core::get_global('user')->id) &&
                                                                        !$this->networkChecker->check(AccessLevelEnum::TYPE_NETWORK, Core::get_global('user')->id)
                                                                    ) {
                                                        Severity: Minor
                                                        Found in src/Module/Application/Playback/Play2Action.php and 1 other location - About 45 mins to fix
                                                        src/Module/Application/Playback/PlayAction.php on lines 440..449

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

                                                        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

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

                                                                if ($transcode) {
                                                                    $transcode_settings = $media->get_transcode_settings($transcode_to, $player, $troptions);
                                                                    if ($bitrate) {
                                                                        $troptions['bitrate'] = ($maxbitrate > 0 && $maxbitrate < $media_bitrate)
                                                                            ? $maxbitrate
                                                        Severity: Minor
                                                        Found in src/Module/Application/Playback/Play2Action.php and 1 other location - About 35 mins to fix
                                                        src/Module/Application/Playback/PlayAction.php on lines 867..913

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

                                                        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

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

                                                                if ((!$user instanceof User || $user->isNew()) && (!$share_id && !$secret)) {
                                                                    $this->logger->error(
                                                                        'No user specified {' . print_r($user, true) . '}',
                                                                        [LegacyLogger::CONTEXT_TYPE => __CLASS__]
                                                                    );
                                                        Severity: Minor
                                                        Found in src/Module/Application/Playback/Play2Action.php and 1 other location - About 30 mins to fix
                                                        src/Module/Application/Playback/PlayAction.php on lines 413..421

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

                                                        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

                                                        Avoid excessively long variable names like $authenticationManager. Keep variable name length under 20.
                                                        Open

                                                                AuthenticationManagerInterface $authenticationManager,

                                                        LongVariable

                                                        Since: 0.2

                                                        Detects when a field, formal or local variable is declared with a long name.

                                                        Example

                                                        class Something {
                                                            protected $reallyLongIntName = -3; // VIOLATION - Field
                                                            public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                                                                $otherReallyLongName = -5; // VIOLATION - Local
                                                                for ($interestingIntIndex = 0; // VIOLATION - For
                                                                     $interestingIntIndex < 10;
                                                                     $interestingIntIndex++ ) {
                                                                }
                                                            }
                                                        }

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

                                                        Avoid excessively long variable names like $authenticationManager. Keep variable name length under 20.
                                                        Open

                                                            private AuthenticationManagerInterface $authenticationManager;

                                                        LongVariable

                                                        Since: 0.2

                                                        Detects when a field, formal or local variable is declared with a long name.

                                                        Example

                                                        class Something {
                                                            protected $reallyLongIntName = -3; // VIOLATION - Field
                                                            public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                                                                $otherReallyLongName = -5; // VIOLATION - Local
                                                                for ($interestingIntIndex = 0; // VIOLATION - For
                                                                     $interestingIntIndex < 10;
                                                                     $interestingIntIndex++ ) {
                                                                }
                                                            }
                                                        }

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

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

                                                                    $i           = 0;

                                                        ShortVariable

                                                        Since: 0.2

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

                                                        Example

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

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

                                                        Expected 0 spaces after opening bracket; newline found
                                                        Open

                                                                    if (

                                                        Expected 0 spaces after opening bracket; newline found
                                                        Open

                                                                    if (

                                                        There are no issues that match your filters.

                                                        Category
                                                        Status