File Model.php
has 1201 lines of code (exceeds 250 allowed). Consider refactoring. Wontfix
<?php
declare(strict_types=1);
namespace Atk4\Data;
- Create a ticketCreate a ticket
Model
has 91 functions (exceeds 20 allowed). Consider refactoring. Open
class Model implements \IteratorAggregate
{
use CollectionTrait {
_addIntoCollection as private __addIntoCollection;
}
- Create a ticketCreate a ticket
Function export
has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring. Open
public function export(?array $fields = null, ?string $keyField = null, bool $typecast = true): array
{
$this->assertHasPersistence('export');
// no key field - then just do export
- Read upRead up
- Create a ticketCreate a ticket
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 save
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function save(array $data = [])
{
$this->getModel()->assertIsWritable();
$this->getModel()->assertHasPersistence();
- Create a ticketCreate a ticket
Function createIteratorBy
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function createIteratorBy($field, $operator = null, $value = null): \Traversable
{
$this->assertIsModel();
$scopeOrig = null;
- Read upRead up
- Create a ticketCreate a ticket
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 setOrder
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function setOrder($field, string $direction = 'asc')
{
$this->assertIsModel();
// fields passed as array
- Read upRead up
- Create a ticketCreate a ticket
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 export
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function export(?array $fields = null, ?string $keyField = null, bool $typecast = true): array
{
$this->assertHasPersistence('export');
// no key field - then just do export
- Create a ticketCreate a ticket
Method createIteratorBy
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function createIteratorBy($field, $operator = null, $value = null): \Traversable
{
$this->assertIsModel();
$scopeOrig = null;
- Create a ticketCreate a ticket
Method _load
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function _load(bool $fromReload, bool $fromTryLoad, $id)
{
$this->getModel()->assertHasPersistence();
if ($this->isLoaded()) {
throw new Exception('Entity must be unloaded');
- Create a ticketCreate a ticket
Function _load
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private function _load(bool $fromReload, bool $fromTryLoad, $id)
{
$this->getModel()->assertHasPersistence();
if ($this->isLoaded()) {
throw new Exception('Entity must be unloaded');
- Read upRead up
- Create a ticketCreate a ticket
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
Consider simplifying this complex logical expression. Open
if (($f === 'system' && $field->system)
|| ($f === 'not system' && !$field->system)
|| ($f === 'editable' && $field->isEditable())
|| ($f === 'visible' && $field->isVisible())
) {
- Create a ticketCreate a ticket
Method set
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function set(string $field, $value)
{
$this->getModel()->assertOnlyField($field);
$f = $this->getField($field);
- Create a ticketCreate a ticket
Method setOrder
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function setOrder($field, string $direction = 'asc')
{
$this->assertIsModel();
// fields passed as array
- Create a ticketCreate a ticket
Method getFields
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getFields($filter = null): array
{
if ($this->isEntity()) {
return $this->getModel()->getFields($filter);
}
- Create a ticketCreate a ticket
Function set
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function set(string $field, $value)
{
$this->getModel()->assertOnlyField($field);
$f = $this->getField($field);
- Read upRead up
- Create a ticketCreate a ticket
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 _insert
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function _insert(array $row): void
{
// find any row values that do not correspond to fields, they may correspond to references instead
$refs = [];
foreach ($row as $key => $value) {
- Read upRead up
- Create a ticketCreate a ticket
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 insert
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function insert(array $row)
{
$entity = $this->createEntity();
$hasRefs = false;
- Read upRead up
- Create a ticketCreate a ticket
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;
- Create a ticketCreate a ticket
Avoid too many return
statements within this method. Open
return $this;
- Create a ticketCreate a ticket
Avoid too many return
statements within this method. Open
return $res;
- Create a ticketCreate a ticket
Avoid too many return
statements within this method. Open
return $this;
- Create a ticketCreate a ticket
Function getModelOnlyProperties
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function getModelOnlyProperties(): array
{
$this->assertIsModel();
if ((self::$_modelOnlyProperties ?? null) === null) {
- Read upRead up
- Create a ticketCreate a ticket
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"