ampache/ampache

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

Summary

Maintainability
B
6 hrs
Test Coverage

Live_Stream has 33 functions (exceeds 20 allowed). Consider refactoring.
Open

class Live_Stream extends database_object implements Media, library_item, CatalogItemInterface
{
    protected const DB_TABLENAME = 'live_stream';

    /* DB based variables */
Severity: Minor
Found in src/Repository/Model/Live_Stream.php - About 4 hrs to fix

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

    class Live_Stream extends database_object implements Media, library_item, CatalogItemInterface
    {
        protected const DB_TABLENAME = 'live_stream';
    
        /* DB based variables */
    Severity: Minor
    Found in src/Repository/Model/Live_Stream.php by phpmd

    The class Live_Stream has 46 public methods and attributes. Consider reducing the number of public items to less than 45.
    Open

    class Live_Stream extends database_object implements Media, library_item, CatalogItemInterface
    {
        protected const DB_TABLENAME = 'live_stream';
    
        /* DB based variables */
    Severity: Minor
    Found in src/Repository/Model/Live_Stream.php by phpmd

    ExcessivePublicCount

    Since: 0.1

    A large number of public methods and attributes declared in a class can indicate the class may need to be broken up as increased effort will be required to thoroughly test it.

    Example

    public class Foo {
        public $value;
        public $something;
        public $var;
        // [... more more public attributes ...]
    
        public function doWork() {}
        public function doMoreWork() {}
        public function doWorkAgain() {}
        // [... more more public methods ...]
    }

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

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

        public static function create(array $data): ?string
        {
            // Make sure we've got a name and codec
            if (!strlen((string)$data['name'])) {
                AmpError::add('name', T_('Name is required'));
    Severity: Minor
    Found in src/Repository/Model/Live_Stream.php - About 55 mins to fix

    Cognitive Complexity

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

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

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

    Further reading

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

        public function play_url($additional_params = '', $player = '', $local = false, $sid = '', $force_http = ''): string
    Severity: Minor
    Found in src/Repository/Model/Live_Stream.php - About 35 mins to fix

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

          public function update(array $data)
          {
              if (!$data['name']) {
                  AmpError::add('general', T_('Name is required'));
              }
      Severity: Minor
      Found in src/Repository/Model/Live_Stream.php - About 25 mins to fix

      Cognitive Complexity

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

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

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

      Further reading

      Avoid unused parameters such as '$local'.
      Open

          public function play_url($additional_params = '', $player = '', $local = false, $sid = '', $force_http = ''): string
      Severity: Minor
      Found in src/Repository/Model/Live_Stream.php by phpmd

      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 '$sid'.
      Open

          public function play_url($additional_params = '', $player = '', $local = false, $sid = '', $force_http = ''): string
      Severity: Minor
      Found in src/Repository/Model/Live_Stream.php by phpmd

      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 '$player'.
      Open

          public function get_stream_types($player = null): array
      Severity: Minor
      Found in src/Repository/Model/Live_Stream.php by phpmd

      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 '$player'.
      Open

          public function play_url($additional_params = '', $player = '', $local = false, $sid = '', $force_http = ''): string
      Severity: Minor
      Found in src/Repository/Model/Live_Stream.php by phpmd

      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 '$target'.
      Open

          public function get_transcode_settings($target = null, $player = null, $options = array()): array
      Severity: Minor
      Found in src/Repository/Model/Live_Stream.php by phpmd

      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 '$force_http'.
      Open

          public function play_url($additional_params = '', $player = '', $local = false, $sid = '', $force_http = ''): string
      Severity: Minor
      Found in src/Repository/Model/Live_Stream.php by phpmd

      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 '$player'.
      Open

          public function get_transcode_settings($target = null, $player = null, $options = array()): array
      Severity: Minor
      Found in src/Repository/Model/Live_Stream.php by phpmd

      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 '$options'.
      Open

          public function get_transcode_settings($target = null, $player = null, $options = array()): array
      Severity: Minor
      Found in src/Repository/Model/Live_Stream.php by phpmd

      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 'int' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST)
      Open

          public int $id = 0;
      Severity: Critical
      Found in src/Repository/Model/Live_Stream.php by phan

      The parameter $user_id is not named in camelCase.
      Open

          public function set_played($user_id, $agent, $location, $date): bool
          {
              // Do nothing
              unset($user_id, $agent, $location, $date);
      
      
      Severity: Minor
      Found in src/Repository/Model/Live_Stream.php by phpmd

      CamelCaseParameterName

      Since: 0.2

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

      Example

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

      Source

      The parameter $additional_params is not named in camelCase.
      Open

          public function play_url($additional_params = '', $player = '', $local = false, $sid = '', $force_http = ''): string
          {
              return $this->url . $additional_params;
          }
      Severity: Minor
      Found in src/Repository/Model/Live_Stream.php by phpmd

      CamelCaseParameterName

      Since: 0.2

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

      Example

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

      Source

      The parameter $force_http is not named in camelCase.
      Open

          public function play_url($additional_params = '', $player = '', $local = false, $sid = '', $force_http = ''): string
          {
              return $this->url . $additional_params;
          }
      Severity: Minor
      Found in src/Repository/Model/Live_Stream.php by phpmd

      CamelCaseParameterName

      Since: 0.2

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

      Example

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

      Source

      The parameter $stream_id is not named in camelCase.
      Open

          public function __construct($stream_id = 0)
          {
              if (!$stream_id) {
                  return;
              }
      Severity: Minor
      Found in src/Repository/Model/Live_Stream.php by phpmd

      CamelCaseParameterName

      Since: 0.2

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

      Example

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

      Source

      The parameter $filter_type is not named in camelCase.
      Open

          public function get_medias(?string $filter_type = null): array
          {
              $medias = array();
              if ($filter_type === null || $filter_type === 'live_stream') {
                  $medias[] = array(
      Severity: Minor
      Found in src/Repository/Model/Live_Stream.php by phpmd

      CamelCaseParameterName

      Since: 0.2

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

      Example

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

      Source

      The class Live_Stream is not named in CamelCase.
      Open

      class Live_Stream extends database_object implements Media, library_item, CatalogItemInterface
      {
          protected const DB_TABLENAME = 'live_stream';
      
          /* DB based variables */
      Severity: Minor
      Found in src/Repository/Model/Live_Stream.php by phpmd

      CamelCaseClassName

      Since: 0.2

      It is considered best practice to use the CamelCase notation to name classes.

      Example

      class class_name {
      }

      Source

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

          public int $id = 0;
      Severity: Minor
      Found in src/Repository/Model/Live_Stream.php by phpmd

      ShortVariable

      Since: 0.2

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

      Example

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

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

      Class name "Live_Stream" is not in camel caps format
      Open

      class Live_Stream extends database_object implements Media, library_item, CatalogItemInterface

      There are no issues that match your filters.

      Category
      Status