modRestController
has 49 functions (exceeds 20 allowed). Consider refactoring. Open
abstract class modRestController {
/** @var modX $modx The modX instance */
public $modx;
/** @var array $config An array of configuration properties, passed from modRestService */
public $config = array();
File modrestcontroller.class.php
has 410 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/*
* This file is part of the MODX Revolution package.
*
* Copyright (c) MODX, LLC
Function put
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function put() {
$id = $this->getProperty($this->primaryKeyField,false);
if (empty($id)) {
return $this->failure($this->modx->lexicon('rest.err_field_ns',array(
'field' => $this->primaryKeyField,
- 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 put
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function put() {
$id = $this->getProperty($this->primaryKeyField,false);
if (empty($id)) {
return $this->failure($this->modx->lexicon('rest.err_field_ns',array(
'field' => $this->primaryKeyField,
Function post
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function post() {
$properties = $this->getProperties();
if (!empty($this->postRequiredFields)) {
if (!$this->checkRequiredFields($this->postRequiredFields)) {
- 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 delete
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function delete() {
$id = $this->getProperty($this->primaryKeyField,false);
if (empty($id)) {
return $this->failure($this->modx->lexicon('rest.err_field_ns',array(
'field' => $this->primaryKeyField,
Method post
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function post() {
$properties = $this->getProperties();
if (!empty($this->postRequiredFields)) {
if (!$this->checkRequiredFields($this->postRequiredFields)) {
Function checkRequiredFields
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function checkRequiredFields(array $fields = array(),$setFieldError = true) {
$missing = array();
foreach ($fields as $field) {
$value = $this->getProperty($field);
- 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 setDefault
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function setDefault($k,$v,$useNotEmpty = false) {
$isSet = false;
if ($useNotEmpty) {
if (!empty($this->properties[$k])) $isSet = true;
} else if (array_key_exists($k,$this->properties)) {
- 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 setObjectFields
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function setObjectFields(&$object,array $values = array()) {
foreach ($values as $key => $value) {
if (is_array($value)) {
foreach ($value as $k => $v) {
$object->{$key[$k]} = $v;
- 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 checkRequiredRelatedObjects
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function checkRequiredRelatedObjects(array $pairs = array()) {
$passed = true;
foreach ($pairs as $field => $classKey) {
if (!empty($classKey) && !empty($field)) {
$relatedObject = $this->modx->getObject($classKey,$this->getProperty($field));
- 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 delete
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function delete() {
$id = $this->getProperty($this->primaryKeyField,false);
if (empty($id)) {
return $this->failure($this->modx->lexicon('rest.err_field_ns',array(
'field' => $this->primaryKeyField,
- 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 $this->success('',$objectArray);
Avoid too many return
statements within this method. Open
return $this->failure();
Avoid too many return
statements within this method. Open
return $this->failure($this->modx->lexicon('rest.err_class_save',array(
'class_key' => $this->classKey,
)));
Avoid too many return
statements within this method. Open
return $this->failure($this->modx->lexicon('rest.err_class_save',array(
'class_key' => $this->classKey,
)));
Avoid too many return
statements within this method. Open
return $this->success('',$objectArray);
Avoid too many return
statements within this method. Open
return $this->failure($this->modx->lexicon('rest.err_class_remove',array(
'class_key' => $this->classKey,
)));
Avoid too many return
statements within this method. Open
return $this->failure($beforePut === false ? $this->errorMessage : $beforePut);
Avoid too many return
statements within this method. Open
return $this->success('',$objectArray);
Function addSearchQuery
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function addSearchQuery(xPDOQuery $c) {
$search = $this->getProperty($this->getOption('propertySearch','search'),false);
if (!empty($search) && !empty($this->searchFields)) {
$searchQuery = array();
$i = 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"