YetiForceCompany/YetiForceCRM

View on GitHub
app/Fields/RangeTime.php

Summary

Maintainability
B
6 hrs
Test Coverage
D
67%

Method formatToRangeText has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function formatToRangeText($value, $mode = 'short', $showEmptyValue = true, $unit = 'h')
    {
        $full = $short = [];
        $hours = (int) $value;
        if ('y' === $unit) {
Severity: Minor
Found in app/Fields/RangeTime.php - About 1 hr to fix

    Function getIntervalPart has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function getIntervalPart(\DateInterval $dateInterval, string $formatOut = 'ahis')
        {
            $value = 0;
            $parts = str_split($formatOut, 1);
            foreach (['a', 'h', 'i', 's'] as $part) {
    Severity: Minor
    Found in app/Fields/RangeTime.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 displayElapseTime has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function displayElapseTime($interval, string $formatIn = 'i', string $formatOut = 'ahi', bool $short = true): string
        {
            $dateFormat = [];
            $multiplier = 1;
            switch ($formatIn) {
    Severity: Minor
    Found in app/Fields/RangeTime.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 formatToRangeText has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function formatToRangeText($value, $mode = 'short', $showEmptyValue = true, $unit = 'h')
        {
            $full = $short = [];
            $hours = (int) $value;
            if ('y' === $unit) {
    Severity: Minor
    Found in app/Fields/RangeTime.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 displayElapseTime has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function displayElapseTime($interval, string $formatIn = 'i', string $formatOut = 'ahi', bool $short = true): string
        {
            $dateFormat = [];
            $multiplier = 1;
            switch ($formatIn) {
    Severity: Minor
    Found in app/Fields/RangeTime.php - About 1 hr to fix

      The method formatToRangeText() has an NPath complexity of 1080. The configured NPath complexity threshold is 200.
      Open

          public static function formatToRangeText($value, $mode = 'short', $showEmptyValue = true, $unit = 'h')
          {
              $full = $short = [];
              $hours = (int) $value;
              if ('y' === $unit) {
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpmd

      NPathComplexity

      Since: 0.1

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

      Example

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

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

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

          public static function displayElapseTime($interval, string $formatIn = 'i', string $formatOut = 'ahi', bool $short = true): string
          {
              $dateFormat = [];
              $multiplier = 1;
              switch ($formatIn) {
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpmd

      CyclomaticComplexity

      Since: 0.1

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

      Example

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

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

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

          public static function formatToRangeText($value, $mode = 'short', $showEmptyValue = true, $unit = 'h')
          {
              $full = $short = [];
              $hours = (int) $value;
              if ('y' === $unit) {
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpmd

      CyclomaticComplexity

      Since: 0.1

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

      Example

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

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

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

          public static function displayElapseTime($interval, string $formatIn = 'i', string $formatOut = 'ahi', bool $short = true): string
      Severity: Critical
      Found in app/Fields/RangeTime.php by sonar-php

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

      See

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

          public static function formatToRangeText($value, $mode = 'short', $showEmptyValue = true, $unit = 'h')
      Severity: Critical
      Found in app/Fields/RangeTime.php by sonar-php

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

      See

      The method displayElapseTime has a boolean flag argument $short, which is a certain sign of a Single Responsibility Principle violation.
      Open

          public static function displayElapseTime($interval, string $formatIn = 'i', string $formatOut = 'ahi', bool $short = true): string
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpmd

      BooleanArgumentFlag

      Since: 1.4.0

      A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

      Example

      class Foo {
          public function bar($flag = true) {
          }
      }

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

      Missing class import via use statement (line '60', column '15').
      Open

                  $dtF = new \DateTime('@0');
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpmd

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

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

      Missing class import via use statement (line '61', column '15').
      Open

                  $dtT = new \DateTime("@{$seconds}");
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpmd

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

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

      The method formatToRangeText has a boolean flag argument $showEmptyValue, which is a certain sign of a Single Responsibility Principle violation.
      Open

          public static function formatToRangeText($value, $mode = 'short', $showEmptyValue = true, $unit = 'h')
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpmd

      BooleanArgumentFlag

      Since: 1.4.0

      A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

      Example

      class Foo {
          public function bar($flag = true) {
          }
      }

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

      Avoid using static access to class '\App\Language' in method 'formatToRangeText'.
      Open

                      $full[] = 1 === $years ? $years . ' ' . \App\Language::translate('LBL_YEAR') : $years . ' ' . \App\Language::translate('LBL_YEARS');
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpmd

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

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

      Avoid using static access to class '\App\Language' in method 'formatToRangeText'.
      Open

                      $full[] = 1 === $days ? $days . ' ' . \App\Language::translate('LBL_DAY') : $days . ' ' . \App\Language::translate('LBL_DAYS');
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpmd

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

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

      Avoid using static access to class '\App\Language' in method 'formatToRangeText'.
      Open

                  $full[] = 1 === $hours ? $hours . ' ' . \App\Language::translate('LBL_HOUR') : $hours . ' ' . \App\Language::translate('LBL_HOURS');
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpmd

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

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

      Avoid using static access to class '\App\Language' in method 'displayElapseTime'.
      Open

                  $dateFormat[] = $short ? $seconds . \App\Language::translate(self::DIFF_INTERVAL_LABELS[$part]['short']) : "{$seconds} " . \App\Language::translate(self::DIFF_INTERVAL_LABELS[$part]['plural']);
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpmd

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

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

      Avoid using static access to class '\App\Language' in method 'formatToRangeText'.
      Open

                      $full[] = 1 === $years ? $years . ' ' . \App\Language::translate('LBL_YEAR') : $years . ' ' . \App\Language::translate('LBL_YEARS');
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpmd

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

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

      Avoid using static access to class '\App\Language' in method 'formatToRangeText'.
      Open

                      $short[] = 1 === $years ? $years . \App\Language::translate('LBL_Y') : $years . \App\Language::translate('LBL_YRS');
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpmd

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

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

      Avoid using static access to class '\App\Language' in method 'formatToRangeText'.
      Open

                      $short[] = 1 === $years ? $years . \App\Language::translate('LBL_Y') : $years . \App\Language::translate('LBL_YRS');
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpmd

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

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

      Avoid using static access to class '\App\Language' in method 'formatToRangeText'.
      Open

                  $short[] = $minutes . \App\Language::translate('LBL_M');
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpmd

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

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

      Avoid using static access to class '\App\Language' in method 'formatToRangeText'.
      Open

                      $full[] = 1 === $days ? $days . ' ' . \App\Language::translate('LBL_DAY') : $days . ' ' . \App\Language::translate('LBL_DAYS');
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpmd

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

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

      Avoid using static access to class '\App\Language' in method 'formatToRangeText'.
      Open

                  $full[] = 1 === $minutes ? $minutes . ' ' . \App\Language::translate('LBL_MINUTE') : $minutes . ' ' . \App\Language::translate('LBL_MINUTES');
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpmd

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

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

      Avoid using static access to class '\App\Language' in method 'formatToRangeText'.
      Open

                  $full[] = 1 === $hours ? $hours . ' ' . \App\Language::translate('LBL_HOUR') : $hours . ' ' . \App\Language::translate('LBL_HOURS');
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpmd

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

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

      Avoid using static access to class '\App\Language' in method 'formatToRangeText'.
      Open

                      $short[] = $days . \App\Language::translate('LBL_D');
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpmd

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

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

      Avoid using static access to class '\App\Language' in method 'displayElapseTime'.
      Open

                          $dateFormat[] = $short ? $val . \App\Language::translate(self::DIFF_INTERVAL_LABELS[$part]['short']) : "{$val} " . \App\Language::translate(self::DIFF_INTERVAL_LABELS[$part][(1 === $val ? 'singular' : 'plural')]);
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpmd

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

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

      Avoid using static access to class '\App\Language' in method 'displayElapseTime'.
      Open

                          $dateFormat[] = $short ? $val . \App\Language::translate(self::DIFF_INTERVAL_LABELS[$part]['short']) : "{$val} " . \App\Language::translate(self::DIFF_INTERVAL_LABELS[$part][(1 === $val ? 'singular' : 'plural')]);
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpmd

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

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

      Avoid using static access to class '\App\Language' in method 'formatToRangeText'.
      Open

                  $short[] = $hours . \App\Language::translate('LBL_H');
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpmd

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

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

      Avoid using static access to class '\App\Language' in method 'displayElapseTime'.
      Open

                  $dateFormat[] = $short ? $seconds . \App\Language::translate(self::DIFF_INTERVAL_LABELS[$part]['short']) : "{$seconds} " . \App\Language::translate(self::DIFF_INTERVAL_LABELS[$part]['plural']);
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpmd

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

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

      Avoid using static access to class '\App\Language' in method 'formatToRangeText'.
      Open

                  $full[] = 1 === $minutes ? $minutes . ' ' . \App\Language::translate('LBL_MINUTE') : $minutes . ' ' . \App\Language::translate('LBL_MINUTES');
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpmd

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

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

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

              'y' => ['short' => 'LBL_Y', 'plural' => 'LBL_YEARS', 'singular' => 'LBL_YEAR'],
      Severity: Critical
      Found in app/Fields/RangeTime.php by sonar-php

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

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

      Noncompliant Code Example

      With the default threshold of 3:

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

      Compliant Solution

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

      Exceptions

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

      Define a constant instead of duplicating this literal "plural" 7 times.
      Open

              'y' => ['short' => 'LBL_Y', 'plural' => 'LBL_YEARS', 'singular' => 'LBL_YEAR'],
      Severity: Critical
      Found in app/Fields/RangeTime.php by sonar-php

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

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

      Noncompliant Code Example

      With the default threshold of 3:

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

      Compliant Solution

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

      Exceptions

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

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

              'y' => ['short' => 'LBL_Y', 'plural' => 'LBL_YEARS', 'singular' => 'LBL_YEAR'],
      Severity: Critical
      Found in app/Fields/RangeTime.php by sonar-php

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

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

      Noncompliant Code Example

      With the default threshold of 3:

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

      Compliant Solution

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

      Exceptions

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

      Expected @param annotation for interval to be before the @param annotation for formatIn
      Open

           * @param string    $formatIn   y,h,m,s
      Severity: Info
      Found in app/Fields/RangeTime.php by phan

      Saw an @param annotation for timePeriod, but it was not found in the param list of function displayElapseTime(mixed $interval, string $formatIn = 'i', string $formatOut = 'ahi', bool|true $short = null) : string
      Open

           * @param int|float $timePeriod Elapse time
      Severity: Info
      Found in app/Fields/RangeTime.php by phan

      Return type of getIntervalPart() is undeclared type \App\Fields\Generator (Did you mean class \Generator)
      Open

          public static function getIntervalPart(\DateInterval $dateInterval, string $formatOut = 'ahis')
      Severity: Minor
      Found in app/Fields/RangeTime.php by phan

      Returning type \Generator but getIntervalPart() is declared to return \App\Fields\Generator
      Open

          public static function getIntervalPart(\DateInterval $dateInterval, string $formatOut = 'ahis')
      Severity: Minor
      Found in app/Fields/RangeTime.php by phan

      Returning type array{short:string,full:string} but formatToRangeText() is declared to return string
      Open

                  'short' => implode(' ', $short),
      Severity: Minor
      Found in app/Fields/RangeTime.php by phan

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

          private static function myBcmod($x, $y)
      Severity: Minor
      Found in app/Fields/RangeTime.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

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

          private static function myBcmod($x, $y)
      Severity: Minor
      Found in app/Fields/RangeTime.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

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

                  $a = (int) $mod . substr($x, 0, $take);
      Severity: Minor
      Found in app/Fields/RangeTime.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

      Spaces must be used to indent lines; tabs are not allowed
      Open

           *
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $dateInterval = $dtF->diff($dtT);
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           * @return Generator
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      $years = (int) floor($val / 365);
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  }
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           */
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              if ($mode && isset(${$mode})) {
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          /**
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              foreach (['a', 'h', 'i', 's'] as $part) {
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $val = (int) $dateInterval->format("%{$part}");
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      $value = 0;
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           * @param mixed  $mode
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          {
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              $full = $short = [];
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  }
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $days = static::myBcmod(($value), (60 * 24 * 365));
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  if (!empty($days)) {
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      $full[] = 1 === $days ? $days . ' ' . \App\Language::translate('LBL_DAY') : $days . ' ' . \App\Language::translate('LBL_DAYS');
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  case 'i':
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  default:
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           *
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  yield [$val, $part];
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          }
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           * @param mixed  $unit
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  }
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $short[] = $hours . \App\Language::translate('LBL_H');
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              }
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          /**
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           * @param int|float $timePeriod Elapse time
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           * @param string    $formatIn   y,h,m,s
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          }
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          public static function getIntervalPart(\DateInterval $dateInterval, string $formatOut = 'ahis')
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          {
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              $value = 0;
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              $parts = str_split($formatOut, 1);
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      }
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           *
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           * @return string
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $days = ($days) / (24 * 60);
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $short[] = $minutes . \App\Language::translate('LBL_M');
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              'a' => ['short' => 'LBL_D', 'plural' => 'LBL_DAYS', 'singular' => 'LBL_DAY'],
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          ];
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           * @param string    $formatOut  ahis - a:days(year), h:hours, i:minutes, s:seconds
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           * @param bool      $short
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           *
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              }
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              $seconds = (int) ((float) $interval * $multiplier);
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  }
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           *
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  if ('a' === $part && $val > 365 && \in_array($part, $parts)) {
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           * @param string $value          Date time
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      $short[] = 1 === $years ? $years . \App\Language::translate('LBL_Y') : $years . \App\Language::translate('LBL_YRS');
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      $short[] = $days . \App\Language::translate('LBL_D');
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              's' => ['short' => 'LBL_S', 'plural' => 'LBL_SECONDS', 'singular' => 'LBL_SECOND'],
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      if ($val) {
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $part = substr($formatOut, -1) ?: 'i';
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              if ('y' === $unit || 'd' === $unit) {
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Line exceeds 120 characters; contains 143 characters
      Open

                      $full[] = 1 === $days ? $days . ' ' . \App\Language::translate('LBL_DAY') : $days . ' ' . \App\Language::translate('LBL_DAYS');
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              }
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              $hours = ($hours) / (60);
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              $minutes = static::myBcmod(($value), (60));
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      $multiplier = 60 * 24 * 365;
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $dtT = new \DateTime("@{$seconds}");
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $dateFormat[] = $short ? $seconds . \App\Language::translate(self::DIFF_INTERVAL_LABELS[$part]['short']) : "{$seconds} " . \App\Language::translate(self::DIFF_INTERVAL_LABELS[$part]['plural']);
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              }
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           * Function returns the date in user specified format.
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              $hours = (int) $value;
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Line exceeds 120 characters; contains 144 characters
      Open

                  $full[] = 1 === $hours ? $hours . ' ' . \App\Language::translate('LBL_HOUR') : $hours . ' ' . \App\Language::translate('LBL_HOURS');
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  return implode(' ', ${$mode});
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  foreach (self::getIntervalPart($dateInterval, $formatOut) as [$val, $part]) {
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      } elseif ('h' === $part || 'i' === $part) {
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $full[] = 1 === $hours ? $hours . ' ' . \App\Language::translate('LBL_HOUR') : $hours . ' ' . \App\Language::translate('LBL_HOURS');
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Line exceeds 120 characters; contains 154 characters
      Open

                  $full[] = 1 === $minutes ? $minutes . ' ' . \App\Language::translate('LBL_MINUTE') : $minutes . ' ' . \App\Language::translate('LBL_MINUTES');
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  case 'h':
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Line exceeds 120 characters; contains 233 characters
      Open

                          $dateFormat[] = $short ? $val . \App\Language::translate(self::DIFF_INTERVAL_LABELS[$part]['short']) : "{$val} " . \App\Language::translate(self::DIFF_INTERVAL_LABELS[$part][(1 === $val ? 'singular' : 'plural')]);
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                          $value = ($val + $value) * 60;
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $days = floor($days);
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              $minutes = floor($minutes);
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           * @var array Interval labels
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           * @return string
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      continue;
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      $full[] = 1 === $years ? $years . ' ' . \App\Language::translate('LBL_YEAR') : $years . ' ' . \App\Language::translate('LBL_YEARS');
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Line exceeds 120 characters; contains 148 characters
      Open

                      $full[] = 1 === $years ? $years . ' ' . \App\Language::translate('LBL_YEAR') : $years . ' ' . \App\Language::translate('LBL_YEARS');
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $hours = static::myBcmod(($value), (24 * 60));
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              if (!empty($minutes) || $showEmptyValue) {
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           */
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           * Get the current interval in a human readable format.
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           * @param mixed     $interval
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          public static function displayElapseTime($interval, string $formatIn = 'i', string $formatOut = 'ahi', bool $short = true): string
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              switch ($formatIn) {
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      break;
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      break;
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      break;
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              if ($seconds) {
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      yield [$years, 'y'];
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  if (!\in_array($part, $parts)) {
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  }
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $value = 0;
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           *
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Line exceeds 120 characters; contains 132 characters
      Open

                      $short[] = 1 === $years ? $years . \App\Language::translate('LBL_Y') : $years . \App\Language::translate('LBL_YRS');
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              'h' => ['short' => 'LBL_H', 'plural' => 'LBL_HOURS', 'singular' => 'LBL_HOUR'],
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              'i' => ['short' => 'LBL_M', 'plural' => 'LBL_MINUTES', 'singular' => 'LBL_MINUTE'],
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Line exceeds 120 characters; contains 134 characters
      Open

          public static function displayElapseTime($interval, string $formatIn = 'i', string $formatOut = 'ahi', bool $short = true): string
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  case 'y':
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           * Get data interval part.
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      if ('a' === $part) {
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          /**
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $years = floor($years);
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           * @param string        $formatOut
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           */
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                          $value = $val * 24;
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              if ('y' === $unit) {
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              }
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              }
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          const DIFF_INTERVAL_LABELS = [
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              'y' => ['short' => 'LBL_Y', 'plural' => 'LBL_YEARS', 'singular' => 'LBL_YEAR'],
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           */
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              $dateFormat = [];
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              $multiplier = 1;
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      $multiplier = 60;
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              } elseif ($formatOut) {
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Line exceeds 120 characters; contains 205 characters
      Open

                  $dateFormat[] = $short ? $seconds . \App\Language::translate(self::DIFF_INTERVAL_LABELS[$part]['short']) : "{$seconds} " . \App\Language::translate(self::DIFF_INTERVAL_LABELS[$part]['plural']);
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              return implode(' ', $dateFormat);
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      $val = (int) static::myBcmod(($val), 365);
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $val += $value;
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           * @param mixed  $showEmptyValue
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $years = ((int) $value) / (60 * 24 * 365);
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              if (!empty($hours)) {
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          {
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $dtF = new \DateTime('@0');
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              }
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           * @param \DateInterval $dateInterval
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              $hours = floor($hours);
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $full[] = 1 === $minutes ? $minutes . ' ' . \App\Language::translate('LBL_MINUTE') : $minutes . ' ' . \App\Language::translate('LBL_MINUTES');
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          /**
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      $multiplier = 60 * 60;
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                          $dateFormat[] = $short ? $val . \App\Language::translate(self::DIFF_INTERVAL_LABELS[$part]['short']) : "{$val} " . \App\Language::translate(self::DIFF_INTERVAL_LABELS[$part][(1 === $val ? 'singular' : 'plural')]);
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      }
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          public static function formatToRangeText($value, $mode = 'short', $showEmptyValue = true, $unit = 'h')
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  if (!empty($years)) {
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              }
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              return [
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          /**
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           * */
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              return (int) $mod;
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $mod = $a % $y;
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              } while (\strlen($x));
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           *
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           * @param mixed $x
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  'full' => implode(' ', $full),
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              ];
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              do {
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           * myBcmod - get modulus (substitute for bcmod)
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           * by Andrius Baranauskas and Laurynas Butkus :) Vilnius, Lithuania.
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          {
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           * string my_bcmod ( string left_operand, int modulus )
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           * @param mixed $y
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              // how many numbers to take at once? carefull not to exceed (int)
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              $mod = '';
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          }
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

              $take = 5;
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $a = (int) $mod . substr($x, 0, $take);
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $x = substr($x, $take);
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          }
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  'short' => implode(' ', $short),
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

           * left_operand can be really big, but be carefull with modulus :(
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      Spaces must be used to indent lines; tabs are not allowed
      Open

          private static function myBcmod($x, $y)
      Severity: Minor
      Found in app/Fields/RangeTime.php by phpcodesniffer

      There are no issues that match your filters.

      Category
      Status