detain/myadmin-ip-webhosting-addon

View on GitHub
src/Plugin.php

Summary

Maintainability
C
1 day
Test Coverage

Function doEnable has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    public static function doEnable(\ServiceHandler $serviceOrder, $repeatInvoiceId, $regexMatch = false)
    {
        $serviceInfo = $serviceOrder->getServiceInfo();
        $settings = get_module_settings(self::$module);
        if ($regexMatch === false) {
Severity: Minor
Found in src/Plugin.php - About 2 hrs 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 doEnable has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function doEnable(\ServiceHandler $serviceOrder, $repeatInvoiceId, $regexMatch = false)
    {
        $serviceInfo = $serviceOrder->getServiceInfo();
        $settings = get_module_settings(self::$module);
        if ($regexMatch === false) {
Severity: Minor
Found in src/Plugin.php - About 1 hr to fix

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

        public static function doDisable(\ServiceHandler $serviceOrder, $repeatInvoiceId, $regexMatch = false)
        {
            $serviceInfo = $serviceOrder->getServiceInfo();
            $settings = get_module_settings(self::$module);
            $db = get_module_db(self::$module);
    Severity: Minor
    Found in src/Plugin.php - About 1 hr to fix

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

          public static function getIps(\xmlapi $whm)
          {
              $ips = [
                  'main' => '',
                  'used' => [],
      Severity: Minor
      Found in src/Plugin.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 doDisable has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function doDisable(\ServiceHandler $serviceOrder, $repeatInvoiceId, $regexMatch = false)
          {
              $serviceInfo = $serviceOrder->getServiceInfo();
              $settings = get_module_settings(self::$module);
              $db = get_module_db(self::$module);
      Severity: Minor
      Found in src/Plugin.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

      Missing class import via use statement (line '188', column '26').
      Open

                          (new \MyAdmin\Mail())->adminMail($subject, $subject, false, 'admin/website_no_ips.tpl');
      Severity: Minor
      Found in src/Plugin.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 '131', column '34').
      Open

                                  (new \MyAdmin\Mail())->adminMail($subject, $subject, false, 'admin/website_no_ips.tpl');
      Severity: Minor
      Found in src/Plugin.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 '135', column '30').
      Open

                              (new \MyAdmin\Mail())->adminMail($subject, "webserver {$serviceInfo[$settings['PREFIX'].'_id']} Has Pending IPS<br>\n".$subject, false, 'admin/website_no_ips.tpl');
      Severity: Minor
      Found in src/Plugin.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 '197', column '14').
      Open

              (new \MyAdmin\Mail())->adminMail($subject, $email, false, 'admin/website_ip_canceled.tpl');
      Severity: Minor
      Found in src/Plugin.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 '48', column '22').
      Open

              $addon = new \AddonHandler();
      Severity: Minor
      Found in src/Plugin.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 '105', column '28').
      Open

                      $whm = new \xmlapi($serverdata[$settings['PREFIX'].'_ip']);
      Severity: Minor
      Found in src/Plugin.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 '165', column '24').
      Open

                  $whm = new \xmlapi($serverdata['website_ip']);
      Severity: Minor
      Found in src/Plugin.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

      There are no issues that match your filters.

      Category
      Status