Function toArray
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public static function toArray( $xml ) {
if ( is_string( $xml ) ) $xml = new SimpleXMLElement( $xml );
$children = $xml->children();
if ( !$children ) return (string) $xml;
$arr = array();
- 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 toXML
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public static function toXML( $data, $rootNodeName = 'ResultSet', &$xml=null ) {
// turn off compatibility mode as simple xml throws a wobbly if you don't.
if ( ini_get('zend.ze1_compatibility_mode') == 1 ) ini_set ( 'zend.ze1_compatibility_mode', 0 );
if ( is_null( $xml ) ) $xml = simplexml_load_string('<?xml version="1.0" encoding="UTF-8" standalone="yes"?><'.$rootNodeName.'></'.$rootNodeName.'>');
- 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
Method setUrl
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function setUrl($ch,$host,$path,$method = 'GET',array $params = array(),array $options = array()) {
$q = http_build_query($params);
switch ($method) {
case 'GET':
$path .= (strpos($host,'?') === false ? '?' : '&').$q;
Function setUrl
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function setUrl($ch,$host,$path,$method = 'GET',array $params = array(),array $options = array()) {
$q = http_build_query($params);
switch ($method) {
case 'GET':
$path .= (strpos($host,'?') === false ? '?' : '&').$q;
- 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 setAuth
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function setAuth($ch,array $options = array()) {
$auth = false;
if (!empty($options[modRestClient::OPT_USERPWD])) {
$options[modRestClient::OPT_AUTHTYPE] = $this->modx->getOption(modRestClient::OPT_AUTHTYPE,$options,'BASIC');
switch ($options[modRestClient::OPT_AUTHTYPE]) {
- 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 setProxy
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function setProxy($ch,array $options = array()) {
$proxyEnabled = false;
/* if proxy is set, attempt to use it */
$proxyHost = $this->modx->getOption('proxy_host',null,'');
if (!empty($proxyHost)) {
- 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
Method setUrl
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function setUrl($ch,$host,$path,$method = 'GET',array $params = array(),array $options = array()) {
Function setOptions
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function setOptions($ch,array $options = array()) {
/* always return us the result */
curl_setopt($ch, CURLOPT_RETURNTRANSFER, !empty($options['curlopt_returntransfer']) ? $options['curlopt_returntransfer'] : 1);
/* we dont want header gruft */
curl_setopt($ch, CURLOPT_HEADER, !empty($options['curlopt_header']) ? $options['curlopt_header'] : 0);
- 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
Method request
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function request($host,$path,$method = 'GET',array $params = array(),array $options = array()) {