detain/myadmin-opensrs-domains

View on GitHub
src/OpenSRS.php

Summary

Maintainability
F
1 wk
Test Coverage

Function searchDomain has a Cognitive Complexity of 87 (exceeds 5 allowed). Consider refactoring.
Open

    public static function searchDomain($domain, $function)
    {
        $final = [];
        $tlds = get_available_domain_tlds_by_tld();
        $tldPrices = get_service_tld_pricing();
Severity: Minor
Found in src/OpenSRS.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

File OpenSRS.php has 680 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * OpenSRS Domain Related Functionality
 * @author Joe Huss <detain@interserver.net>
 * @copyright 2019
Severity: Major
Found in src/OpenSRS.php - About 1 day to fix

    Function listDomainsByExpireyDate has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function listDomainsByExpireyDate($startDate = false, $endDate = false)
        {
            if ($startDate == false) {
                $startDate = date('Y-m-d', strtotime(date('Y').'-01-01 +45 days'));
            }
    Severity: Minor
    Found in src/OpenSRS.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

    Method getEventTypes has 87 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function getEventTypes()
        {
            return [
                'types' => [
                    'domain' => [
    Severity: Major
    Found in src/OpenSRS.php - About 3 hrs to fix

      Method xmlRequest has 77 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function xmlRequest($action, $object, $options, $extra = null)
          {
              $username = OPENSRS_USERNAME;
              $privateKey = OPENSRS_KEY;
              $xml = '<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
      Severity: Major
      Found in src/OpenSRS.php - About 3 hrs to fix

        Method searchDomain has 68 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function searchDomain($domain, $function)
            {
                $final = [];
                $tlds = get_available_domain_tlds_by_tld();
                $tldPrices = get_service_tld_pricing();
        Severity: Major
        Found in src/OpenSRS.php - About 2 hrs to fix

          OpenSRS has 22 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class OpenSRS
          {
              public $id;
              public $cookie;
              public $osrsHandlerAllInfo;
          Severity: Minor
          Found in src/OpenSRS.php - About 2 hrs to fix

            Method loadDomainInfo has 57 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function loadDomainInfo()
                {
                    $callstring = [
                        'func' => 'lookupGetDomain',
                        'attributes' => [
            Severity: Major
            Found in src/OpenSRS.php - About 2 hrs to fix

              Function xmlRequest has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function xmlRequest($action, $object, $options, $extra = null)
                  {
                      $username = OPENSRS_USERNAME;
                      $privateKey = OPENSRS_KEY;
                      $xml = '<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
              Severity: Minor
              Found in src/OpenSRS.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 listDomainsByExpireyDate has 53 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static function listDomainsByExpireyDate($startDate = false, $endDate = false)
                  {
                      if ($startDate == false) {
                          $startDate = date('Y-m-d', strtotime(date('Y').'-01-01 +45 days'));
                      }
              Severity: Major
              Found in src/OpenSRS.php - About 2 hrs to fix

                The class OpenSRS has 17 fields. Consider redesigning OpenSRS to keep the number of fields under 15.
                Open

                class OpenSRS
                {
                    public $id;
                    public $cookie;
                    public $osrsHandlerAllInfo;
                Severity: Minor
                Found in src/OpenSRS.php by phpmd

                TooManyFields

                Since: 0.1

                Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.

                Example

                class Person {
                   protected $one;
                   private $two;
                   private $three;
                   [... many more fields ...]
                }

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

                Function checkDomainAvailable has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                    public static function checkDomainAvailable($domain)
                    {
                        $result = self::lookupDomain($domain);
                        if ($result === false) {
                            return false;
                Severity: Minor
                Found in src/OpenSRS.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 request has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static function request($callstring)
                    {
                        if (is_string($callstring)) {
                            $callstring = json_decode($callstring, true);
                            $action = $callstring['func'];
                Severity: Minor
                Found in src/OpenSRS.php - About 1 hr to fix

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

                      public static function request($callstring)
                      {
                          if (is_string($callstring)) {
                              $callstring = json_decode($callstring, true);
                              $action = $callstring['func'];
                  Severity: Minor
                  Found in src/OpenSRS.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

                  Avoid deeply nested control flow statements.
                  Open

                                                          if (isset($tldPrices[$tld]['new'])) {
                                                              $osrsHandler->resultFullRaw['attributes'][$resultType]['items'][$idx]['new'] = bcadd($tldPrices[$tld]['new'], $diff, 2);
                                                          }
                  Severity: Major
                  Found in src/OpenSRS.php - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                                            if (isset($tldPrices[$tld]['renewal'])) {
                                                                $osrsHandler->resultFullRaw['attributes'][$resultType]['items'][$idx]['renewal'] = bcadd($tldPrices[$tld]['renewal'], $diff, 2);
                                                            }
                    Severity: Major
                    Found in src/OpenSRS.php - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                                              if (isset($tldPrices[$tld]['transfer'])) {
                                                                  if ($tldPrices[$tld]['transfer'] > 0) {
                                                                      $osrsHandler->resultFullRaw['attributes'][$resultType]['items'][$idx]['transfer'] = bcadd($tldPrices[$tld]['transfer'], $diff, 2);
                                                                  } else {
                                                                      $osrsHandler->resultFullRaw['attributes'][$resultType]['items'][$idx]['transfer'] = 0;
                      Severity: Major
                      Found in src/OpenSRS.php - About 45 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                return false;
                        Severity: Major
                        Found in src/OpenSRS.php - About 30 mins to fix

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

                              public static function createNameserverRaw($cookie, $hostname, $ip, $useDomain = false)
                              {
                                  if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
                                      $callstring = [
                                          'func' => 'nsCreate',
                          Severity: Minor
                          Found in src/OpenSRS.php - About 25 mins to fix

                          Cognitive Complexity

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

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

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

                          Further reading

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

                              public static function response_to_array($array)
                              {
                                  $out = [];
                                  if (isset($array['attr'])) {
                                      $array = [$array];
                          Severity: Minor
                          Found in src/OpenSRS.php - About 25 mins to fix

                          Cognitive Complexity

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

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

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

                          Further reading

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

                              public static function pollEvent($limit = 1)
                              {
                                  $response = self::xmlRequest('EVENT', 'POLL', ['limit'=>$limit]);
                                  if ($response['xml_str'] !== false) {
                                      //function_requirements('xml2array');
                          Severity: Minor
                          Found in src/OpenSRS.php - About 25 mins to fix

                          Cognitive Complexity

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

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

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

                          Further reading

                          Avoid using undefined variables such as '$levels' which will lead to PHP notices.
                          Open

                                              myadmin_log('domains', 'error', 'This Line `'.$xml[$error->line - 1].'` gave a '.$levels[$error->level].' #'.$error->code.' `'.$error->message.'` at Line '.$error->line.' Column '.$error->column.' File '.$error->file, __LINE__, __FILE__, self::$module);
                          Severity: Minor
                          Found in src/OpenSRS.php by phpmd

                          UndefinedVariable

                          Since: 2.8.0

                          Detects when a variable is used that has not been defined before.

                          Example

                          class Foo
                          {
                              private function bar()
                              {
                                  // $message is undefined
                                  echo $message;
                              }
                          }

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

                          Avoid unused local variables such as '$idx'.
                          Open

                                          foreach ($response['xml_array']['body']['data_block']['dt_assoc']['item'] as $idx => $data) {
                          Severity: Minor
                          Found in src/OpenSRS.php by phpmd

                          UnusedLocalVariable

                          Since: 0.2

                          Detects when a local variable is declared and/or assigned, but not used.

                          Example

                          class Foo {
                              public function doSomething()
                              {
                                  $i = 5; // Unused
                              }
                          }

                          Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

                          Avoid unused local variables such as '$domainIdx'.
                          Open

                                                          foreach ($domainParentData['dt_array']['item'] as $domainIdx => $domainArray) {
                          Severity: Minor
                          Found in src/OpenSRS.php by phpmd

                          UnusedLocalVariable

                          Since: 0.2

                          Detects when a local variable is declared and/or assigned, but not used.

                          Example

                          class Foo {
                              public function doSomething()
                              {
                                  $i = 5; // Unused
                              }
                          }

                          Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

                          Avoid unused local variables such as '$levels'.
                          Open

                                              myadmin_log('domains', 'error', 'This Line `'.$xml[$error->line - 1].'` gave a '.$levels[$error->level].' #'.$error->code.' `'.$error->message.'` at Line '.$error->line.' Column '.$error->column.' File '.$error->file, __LINE__, __FILE__, self::$module);
                          Severity: Minor
                          Found in src/OpenSRS.php by phpmd

                          UnusedLocalVariable

                          Since: 0.2

                          Detects when a local variable is declared and/or assigned, but not used.

                          Example

                          class Foo {
                              public function doSomething()
                              {
                                  $i = 5; // Unused
                              }
                          }

                          Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

                          Avoid unused local variables such as '$dataIdx'.
                          Open

                                                  foreach ($data['dt_assoc']['item'] as $dataIdx => $domainParentData) {
                          Severity: Minor
                          Found in src/OpenSRS.php by phpmd

                          UnusedLocalVariable

                          Since: 0.2

                          Detects when a local variable is declared and/or assigned, but not used.

                          Example

                          class Foo {
                              public function doSomething()
                              {
                                  $i = 5; // Unused
                              }
                          }

                          Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

                          Avoid excessively long variable names like $osrsHandlerWhoisPrivacy. Keep variable name length under 20.
                          Open

                              public $osrsHandlerWhoisPrivacy;
                          Severity: Minor
                          Found in src/OpenSRS.php by phpmd

                          LongVariable

                          Since: 0.2

                          Detects when a field, formal or local variable is declared with a long name.

                          Example

                          class Something {
                              protected $reallyLongIntName = -3; // VIOLATION - Field
                              public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                                  $otherReallyLongName = -5; // VIOLATION - Local
                                  for ($interestingIntIndex = 0; // VIOLATION - For
                                       $interestingIntIndex < 10;
                                       $interestingIntIndex++ ) {
                                  }
                              }
                          }

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

                          The parameter $event_id is not named in camelCase.
                          Open

                              public static function ackEvent($event_id)
                              {
                                  $response = self::xmlRequest('EVENT', 'ACK', ['event_id'=>$event_id]);
                                  if ($response === false) {
                                      return false;
                          Severity: Minor
                          Found in src/OpenSRS.php by phpmd

                          CamelCaseParameterName

                          Since: 0.2

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

                          Example

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

                          Source

                          The property $error_levels is not named in camelCase.
                          Open

                          class OpenSRS
                          {
                              public $id;
                              public $cookie;
                              public $osrsHandlerAllInfo;
                          Severity: Minor
                          Found in src/OpenSRS.php by phpmd

                          CamelCasePropertyName

                          Since: 0.2

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

                          Example

                          class ClassName {
                              protected $property_name;
                          }

                          Source

                          The variable $event_id is not named in camelCase.
                          Open

                              public static function ackEvent($event_id)
                              {
                                  $response = self::xmlRequest('EVENT', 'ACK', ['event_id'=>$event_id]);
                                  if ($response === false) {
                                      return false;
                          Severity: Minor
                          Found in src/OpenSRS.php by phpmd

                          CamelCaseVariableName

                          Since: 0.2

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

                          Example

                          class ClassName {
                              public function doSomething() {
                                  $data_module = new DataModule();
                              }
                          }

                          Source

                          The variable $event_id is not named in camelCase.
                          Open

                              public static function ackEvent($event_id)
                              {
                                  $response = self::xmlRequest('EVENT', 'ACK', ['event_id'=>$event_id]);
                                  if ($response === false) {
                                      return false;
                          Severity: Minor
                          Found in src/OpenSRS.php by phpmd

                          CamelCaseVariableName

                          Since: 0.2

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

                          Example

                          class ClassName {
                              public function doSomething() {
                                  $data_module = new DataModule();
                              }
                          }

                          Source

                          The method response_to_array is not named in camelCase.
                          Open

                              public static function response_to_array($array)
                              {
                                  $out = [];
                                  if (isset($array['attr'])) {
                                      $array = [$array];
                          Severity: Minor
                          Found in src/OpenSRS.php by phpmd

                          CamelCaseMethodName

                          Since: 0.2

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

                          Example

                          class ClassName {
                              public function get_name() {
                              }
                          }

                          Source

                          There are no issues that match your filters.

                          Category
                          Status