eveseat/services

View on GitHub
src/Helpers/helpers.php

Summary

Maintainability
B
4 hrs
Test Coverage

Method evemail_threads has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function evemail_threads($message)
    {

        // Explode the messages based on the delimiter added
        // by the EVE Online Client.
Severity: Minor
Found in src/Helpers/helpers.php - About 1 hr to fix

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

        function number_roman($number)
        {
    
            $map = [
                'M' => 1000, 'CM' => 900, 'D' => 500, 'CD' => 400, 'C' => 100, 'XC' => 90, 'L' => 50,
    Severity: Minor
    Found in src/Helpers/helpers.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 setting has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        function setting($name, bool $global = false)
        {
    
            // If we received an array, it means we want to set.
            if (is_array($name)) {
    Severity: Minor
    Found in src/Helpers/helpers.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 img has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        function img(string $type, string $variation, ?int $id, int $size, array $attr = [], $lazy = true)
    Severity: Minor
    Found in src/Helpers/helpers.php - About 45 mins to fix

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

          function setting($name, bool $global = false)
      Severity: Minor
      Found in src/Helpers/helpers.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 '35', column '24').
      Open

                  return new \Carbon\Carbon($data);
      Severity: Minor
      Found in src/Helpers/helpers.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 '281', column '27').
      Open

                      throw new \Seat\Services\Exceptions\SettingException(
      Severity: Minor
      Found in src/Helpers/helpers.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 img has a boolean flag argument $lazy, which is a certain sign of a Single Responsibility Principle violation.
      Open

          function img(string $type, string $variation, ?int $id, int $size, array $attr = [], $lazy = true)
      Severity: Minor
      Found in src/Helpers/helpers.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

      Remove error control operator '@' on line 150.
      Open

          function clean_ccp_html($html, $acceptable_tags = '<font><br><i>')
          {
              if (empty($html))
                  return '';
      
      
      Severity: Minor
      Found in src/Helpers/helpers.php by phpmd

      ErrorControlOperator

      Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

      Example

      function foo($filePath) {
          $file = @fopen($filPath); // hides exceptions
          $key = @$array[$notExistingKey]; // assigns null to $key
      }

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

      Missing class import via use statement (line '149', column '20').
      Open

              $dom = new DOMDocument();
      Severity: Minor
      Found in src/Helpers/helpers.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 '37', column '20').
      Open

              return new \Carbon\Carbon;
      Severity: Minor
      Found in src/Helpers/helpers.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 '75', column '23').
      Open

              $image = (new \Seat\Services\Image\Eve($type, $variation, $id, $size, $attr, $lazy))
      Severity: Minor
      Found in src/Helpers/helpers.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

      Avoid using static access to class 'Coduo\PHPHumanizer\NumberHumanizer' in method 'number_metric'.
      Open

              return Coduo\PHPHumanizer\NumberHumanizer::metricSuffix($number);
      Severity: Minor
      Found in src/Helpers/helpers.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 '\Seat\Services\Settings\Profile' in method 'setting'.
      Open

              return \Seat\Services\Settings\Profile::get($name);
      Severity: Minor
      Found in src/Helpers/helpers.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 '\Seat\Services\Settings\Seat' in method 'setting'.
      Open

                      return \Seat\Services\Settings\Seat::set($name[0], $name[1], $for_id);
      Severity: Minor
      Found in src/Helpers/helpers.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 '\Seat\Services\Settings\Profile' in method 'setting'.
      Open

                  return \Seat\Services\Settings\Profile::set($name[0], $name[1], $for_id);
      Severity: Minor
      Found in src/Helpers/helpers.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 '\Seat\Services\Settings\Seat' in method 'setting'.
      Open

                  return \Seat\Services\Settings\Seat::get($name);
      Severity: Minor
      Found in src/Helpers/helpers.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 empty try-catch blocks in evemail_threads.
      Open

                  } catch (InvalidArgumentException $e) {
                  }
      Severity: Minor
      Found in src/Helpers/helpers.php by phpmd

      EmptyCatchBlock

      Since: 2.7.0

      Usually empty try-catch is a bad idea because you are silently swallowing an error condition and then continuing execution. Occasionally this may be the right thing to do, but often it's a sign that a developer saw an exception, didn't know what to do about it, and so used an empty catch to silence the problem.

      Example

      class Foo {
      
        public function bar()
        {
            try {
                // ...
            } catch (Exception $e) {} // empty catch block
        }
      }

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

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

          function img(string $type, string $variation, ?int $id, int $size, array $attr = [], $lazy = true)
      Severity: Minor
      Found in src/Helpers/helpers.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

      There are no issues that match your filters.

      Category
      Status