File Model.php
has 416 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace FOO;
/**
Function offsetSet
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
public function offsetSet($key, $value) {
$schema = static::getSchema();
if(array_key_exists($key, $this->obj)) {
switch($schema[$key][0]) {
case static::T_BOOL:
- 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
Model
has 23 functions (exceeds 20 allowed). Consider refactoring. Open
class Model implements \JsonSerializable, \ArrayAccess {
// Field types
/** Boolean field type. */
const T_BOOL = 0;
/** Numeric (int/float) field type. */
Function generateWhere
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
protected static function generateWhere(array $query) {
$MODEL = 'FOO\\' . static::$MODEL;
$clauses = [];
$vals = [];
- 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 validateField
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
protected function validateField($field, $settings, $value) {
$ok = false;
switch($settings[0]) {
case static::T_BOOL:
$ok = is_bool($value);
- 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 hydrateModels
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public static function hydrateModels($objs) {
$models = [];
foreach($objs as $obj) {
foreach(array_keys($obj) as $key) {
// If a value is numeric, cast it into an int.
- 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 validateField
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function validateField($field, $settings, $value) {
$ok = false;
switch($settings[0]) {
case static::T_BOOL:
$ok = is_bool($value);
Method offsetSet
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function offsetSet($key, $value) {
$schema = static::getSchema();
if(array_key_exists($key, $this->obj)) {
switch($schema[$key][0]) {
case static::T_BOOL:
Method generateClauses
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected static function generateClauses($count=null, $offset=null, $sort=[], $group=[], $reverse=null) {
$MODEL = 'FOO\\' . static::$MODEL;
$clauses = [];
$order = [];
Method generateWhere
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected static function generateWhere(array $query) {
$MODEL = 'FOO\\' . static::$MODEL;
$clauses = [];
$vals = [];
Function generateClauses
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
protected static function generateClauses($count=null, $offset=null, $sort=[], $group=[], $reverse=null) {
$MODEL = 'FOO\\' . static::$MODEL;
$clauses = [];
$order = [];
- 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 generateQuery
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function generateQuery(array $fields, array $query=[], $count=null, $offset=null, $sort=[], $group=[], $reverse=null) {
Method generateClauses
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
protected static function generateClauses($count=null, $offset=null, $sort=[], $group=[], $reverse=null) {
Method getByQuery
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function getByQuery(array $query=[], $count=null, $offset=null, $sort=[], $reverse=null) {
Method countByQuery
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function countByQuery(array $query=[], $count=null, $offset=null, $sort=[], $reverse=null) {
Function delete
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function delete($hard=false) {
if($this->new) {
return false;
}
- 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 generateClause
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected static function generateClause($key, $value) {
$val_cmp = true;
$conds = [];
$vals = [];
- 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 toArray
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function toArray(array $keys=null) {
$ret = [];
if(is_null($keys)) {
$keys = array_keys($this->obj);
} else {
- 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"