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');
}
- Read upRead up
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 [];
}
- Read upRead up
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;
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 [];
}
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');
}
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);
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);
- Read upRead up
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;
}
- Read upRead up
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;
Avoid too many return
statements within this method. Open
return (string) $this->params[$param];
Avoid too many return
statements within this method. Open
return (int) $this->params[$param];
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)
- Read upRead up
- Exclude checks
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)
- Read upRead up
- Exclude checks
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]);
- Read upRead up
- Exclude checks
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();
}