jumper423/decaptcha

View on GitHub
src/core/DeCaptchaAbstract.php

Summary

Maintainability
D
2 days
Test Coverage

Function decodeResponse has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

    protected function decodeResponse($action, $data)
    {
        if (!array_key_exists($action, $this->decodeSettings[static::DECODE_ACTION])) {
            throw new DeCaptchaErrors('нет action');
        }
Severity: Minor
Found in src/core/DeCaptchaAbstract.php - About 4 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

Function getParams has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

    protected function getParams($action, $field = null)
    {
        if (empty($this->actions[$action])) {
            return [];
        }
Severity: Minor
Found in src/core/DeCaptchaAbstract.php - About 3 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

File DeCaptchaAbstract.php has 281 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace jumper423\decaptcha\core;

use Exception;
Severity: Minor
Found in src/core/DeCaptchaAbstract.php - About 2 hrs to fix

    Method getParams has 50 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function getParams($action, $field = null)
        {
            if (empty($this->actions[$action])) {
                return [];
            }
    Severity: Minor
    Found in src/core/DeCaptchaAbstract.php - About 2 hrs to fix

      Method decodeResponse has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function decodeResponse($action, $data)
          {
              if (!array_key_exists($action, $this->decodeSettings[static::DECODE_ACTION])) {
                  throw new DeCaptchaErrors('нет action');
              }
      Severity: Minor
      Found in src/core/DeCaptchaAbstract.php - About 1 hr to fix

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

            protected function curlResponse($url, $data, $isPost = true, $isJson = false)
            {
                $curl = curl_init();
                if ($isJson) {
                    $data = json_encode($data);
        Severity: Minor
        Found in src/core/DeCaptchaAbstract.php - About 1 hr to fix

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

              protected function curlResponse($url, $data, $isPost = true, $isJson = false)
              {
                  $curl = curl_init();
                  if ($isJson) {
                      $data = json_encode($data);
          Severity: Minor
          Found in src/core/DeCaptchaAbstract.php - About 55 mins to fix

          Cognitive Complexity

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

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

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

          Further reading

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

              public function getParamSpec($param, $spec = null, $coding = null)
              {
                  if (is_null($spec)) {
                      $spec = $param;
                  }
          Severity: Minor
          Found in src/core/DeCaptchaAbstract.php - About 35 mins to fix

          Cognitive Complexity

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

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

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

          Further reading

          Avoid too many return statements within this method.
          Open

                  return null;
          Severity: Major
          Found in src/core/DeCaptchaAbstract.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                            return (string) $this->params[$param];
            Severity: Major
            Found in src/core/DeCaptchaAbstract.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                              return (int) $this->params[$param];
              Severity: Major
              Found in src/core/DeCaptchaAbstract.php - About 30 mins to fix

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

                    protected function curlResponse($url, $data, $isPost = true, $isJson = false)
                Severity: Minor
                Found in src/core/DeCaptchaAbstract.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

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

                    protected function curlResponse($url, $data, $isPost = true, $isJson = false)
                Severity: Minor
                Found in src/core/DeCaptchaAbstract.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 '242', column '75').
                Open

                                return (version_compare(PHP_VERSION, '5.5.0') >= 0) ? new \CURLFile($this->getFilePath($this->params[$param])) : '@'.$this->getFilePath($this->params[$param]);
                Severity: Minor
                Found in src/core/DeCaptchaAbstract.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