NgRestModel
has 51 functions (exceeds 20 allowed). Consider refactoring. Open
abstract class NgRestModel extends ActiveRecord implements GenericSearchInterface, NgRestModelInterface
{
/**
* @var string This event will be trigger after the find population of each row when ngrest loads the data from the server to edit data. (When click on edit icon)
*/
File NgRestModel.php
has 454 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace luya\admin\ngrest\base;
use luya\admin\base\GenericSearchInterface;
Function ngRestConfigDefine
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
public function ngRestConfigDefine(ConfigBuilder $config, $assignedType, array $fields)
{
$types = $this->ngRestAttributeTypes();
$extraTypes = $this->ngRestExtraAttributeTypes();
- 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 ngRestConfigDefine
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function ngRestConfigDefine(ConfigBuilder $config, $assignedType, array $fields)
{
$types = $this->ngRestAttributeTypes();
$extraTypes = $this->ngRestExtraAttributeTypes();
Function ngRestConfig
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function ngRestConfig($config)
{
foreach ($this->ngRestScopes() as $arrayConfig) {
if (!isset($arrayConfig[0]) && !isset($arrayConfig[1])) {
throw new InvalidConfigException("Invalid ngRestScope definition. Definition must contain an array with two elements: `['create', []]`");
- 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 i18nAttributeFallbackValue
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function i18nAttributeFallbackValue($attributeName, $preferredLanguage = null)
{
$value = $this->{$attributeName};
if (empty($value) && $this->isI18n($attributeName)) {
- 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 ngRestConfigButtonCondition
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function ngRestConfigButtonCondition($arrayConfig)
{
if (!isset($arrayConfig[2]) || !isset($arrayConfig[2]['buttonCondition'])) {
$buttonCondition = '';
} elseif (is_string($arrayConfig[2]['buttonCondition'])) {
- 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 generateNgRestRelations
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function generateNgRestRelations()
{
$relations = [];
// generate relations
foreach ($this->ngRestRelations() as $key => $item) {
- 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 getNgRestScopeConfigOptions
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function getNgRestScopeConfigOptions($config)
{
$configOptions = [];
foreach ($this->ngRestScopes() as $arrayConfig) {
$scope = is_string($arrayConfig[0]) ? [$arrayConfig[0]] : $arrayConfig[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
Function afterFind
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function afterFind()
{
if ($this->getNgRestCallType()) {
if ($this->getNgRestCallType() == 'list') {
$this->trigger(self::EVENT_AFTER_NGREST_FIND);
- 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"