thcolin/scene-release-parser

View on GitHub
src/Release.php

Summary

Maintainability
F
4 days
Test Coverage

File Release.php has 756 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

  namespace thcolin\SceneReleaseParser;

  use Mhor\MediaInfo\MediaInfo;
Severity: Major
Found in src/Release.php - About 1 day to fix

    Function analyse has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function analyse($path, $config = []){
          if(!is_file($path)){
            throw new InvalidArgumentException("File '".$path."' not found");
          }
    
    
    Severity: Minor
    Found in src/Release.php - About 1 day 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

    Release has 45 functions (exceeds 20 allowed). Consider refactoring.
    Open

      class Release{
    
        const MOVIE = 'movie';
        const TVSHOW = 'tvshow';
    
    
    Severity: Minor
    Found in src/Release.php - About 6 hrs to fix

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

          public static function analyse($path, $config = []){
            if(!is_file($path)){
              throw new InvalidArgumentException("File '".$path."' not found");
            }
      
      
      Severity: Major
      Found in src/Release.php - About 3 hrs to fix

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

            private function parseLanguage(&$title){
              $languages = [];
        
              foreach(self::$languageStatic as $langue => $patterns){
                if(!is_array($patterns)){
        Severity: Minor
        Found in src/Release.php - About 1 hr to fix

        Cognitive Complexity

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

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

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

        Further reading

        Method __construct has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function __construct($name, $strict = true, $defaults = []){
              foreach($defaults as $key => $default){
                $const = $key.'Static';
        
                if(property_exists(get_class(), $const) && !in_array($default, array_keys(self::$$const))){
        Severity: Minor
        Found in src/Release.php - About 1 hr to fix

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

              public function guessResolution(){
                if($this -> resolution){
                  return $this -> resolution;
                } else if($this->getSource() == self::SOURCE_BLURAY || $this->getSource() == self::SOURCE_BDSCR){
                  return self::RESOLUTION_1080P;
          Severity: Minor
          Found in src/Release.php - About 1 hr to fix

          Cognitive Complexity

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

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

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

          Further reading

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

              private function parseAttribute(&$title, $attribute){
                if(!in_array($attribute, [self::SOURCE, self::ENCODING, self::RESOLUTION, self::DUB])){
                  throw new InvalidArgumentException();
                }
          
          
          Severity: Minor
          Found in src/Release.php - About 55 mins to fix

          Cognitive Complexity

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

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

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

          Further reading

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

              private function parseFlags(&$title){
                $flags = [];
          
                foreach(self::$flagsStatic as $key => $patterns){
                  if(!is_array($patterns)){
          Severity: Minor
          Found in src/Release.php - About 45 mins to fix

          Cognitive Complexity

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

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

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

          Further reading

          Function __toString has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public function __toString(){
                $arrays = [];
                foreach([
                  $this -> getTitle(),
                  $this -> getYear(),
          Severity: Minor
          Found in src/Release.php - About 35 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

          There are no issues that match your filters.

          Category
          Status