Showing 44 of 74 total issues
Method getConfigBundle
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getConfigBundle(string $dataTables, bool $cache = true): ConfigBundle {
$dataTablesFQN = $this->parseClassNameToFQN($dataTables);
$dataTablesName = explode('\\', $dataTables);
$dataTablesName = array_pop($dataTablesName);
$configure = TableConfigure::getInstance();
Method getFilesBody
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getFilesBody(array $query, string $type): string {
$files = [];
$md5 = $type . '_' . md5(json_encode($query));
$body = Cache::read($md5, '_data_tables_assets_');
if ($body === null) {
Method checkKeysValueTypesOrFail
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function checkKeysValueTypesOrFail(?array $array, $allowedKeyTypes = [], $allowedValueTypes = [], ?string $inString = null): void {
if (empty($array)) {
return;
}
$allowedKeyTypesType = getType($allowedKeyTypes);
Method init
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function init(): void {
$this->records = [
[
'id' => 1,
'name' => 'Cars',
Method normalizeDataTableField
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function normalizeDataTableField(string $dataBaseField): array {
$ormTable = $this->getConfigBundle()->getDataTables()->getOrmTable();
$explodedDataBaseField = explode('.', $dataBaseField);
if (count($explodedDataBaseField) === 2) {
$table = Inflector::camelize($explodedDataBaseField[0]);
Method getFormattedColumn
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getFormattedColumn(string $columnName, Column $column, EntityInterface $entity): string {
$exploded = explode('.', $columnName);
if (count($exploded) === 2) {
$value = $this->getPropertyUsingPath($column->getAssociationPath(), $entity, $exploded[1]);
$integersTypes = ['tinyinteger', 'smallinteger', 'integer', 'biginteger', 'decimal', 'float'];
Method buildOptionParser
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function buildOptionParser(ConsoleOptionParser $parser): ConsoleOptionParser {
$parser = $this->_setCommonOptions($parser);
$parser->setDescription(
sprintf('Bake the plugin DataTables necessaries files.')
)->addArgument('type', [
Function setColumns
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function setColumns(Columns $columns) {
$columnsConfig = [];
foreach ($columns->getColumns() as $column) {
if ($column->isDatabase() === false) {
$column->setSearchable(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 getConfigAsArray
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function getConfigAsArray(?bool $printAllOptions = null): array {
$assets = $this->_configBundle->Assets;
if ($assets->isAutoload()) {
if (!empty($this->getConfig('select')) && !$assets->isLoadPluginSelect()) {
$assets->setLoadPluginSelect(true);
- 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 getConfig
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function getConfig(bool $onlyDirty = true, bool $isDefaultColumn = false): array {
$result = [];
if ($onlyDirty === false) {
$result = $this->_config;
}
- 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 checkIfHaveCustomItemsInSession
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function checkIfHaveCustomItemsInSession(ConfigBundle $configBundle): ConfigBundle {
$md5s = [
Functions::getInstance()->getConfigBundleAndUrlUniqueMd5($configBundle),
Functions::getInstance()->getConfigBundleAndUrlUniqueMd5($configBundle, true),
];
- 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 __construct
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function __construct(View $view, string $dataTables, string $name, array $url, array $options) {
Method __construct
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function __construct(string $name, bool $database = true, array $columnSchema = [], string $associationPath = '', ?FunctionExpression $functionExpression = null) {
Function setPluginSelectLanguageColumns
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function setPluginSelectLanguageColumns($columns) {
if (!in_array(getType($columns), ['string', 'array'])) {
throw new InvalidArgumentException('Columns must be a string or a array with plural translations.');
} elseif (is_array($columns)) {
$allowedKeys = ['_', '0', '1'];
- 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 setRenderer
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function setRenderer($renderer) {
$rendererType = getType($renderer);
if (!in_array($rendererType, ['string', 'array'])) {
throw new InvalidArgumentException("\$renderer must be a string or array. Found: $rendererType.");
}
- 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 setOrderFixed
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function setOrderFixed(array $orderFixed) {
if (getType(Functions::getInstance()->arrayKeyFirst($orderFixed)) === 'string') {
foreach ($orderFixed as $key => $objectItem) {
if (!in_array($key, ['pre', 'post'])) {
throw new InvalidArgumentException("You must use only 'pre' or 'post' key for objects type. Found: $key.");
- 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 getFind
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function getFind(): Query {
$select = [];
$contains = [];
$columns = $this->_configBundle->Columns;
$table = $this->_configBundle->getDataTables()->getOrmTable();
- 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 setPluginSelectLanguageCells
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function setPluginSelectLanguageCells($cells) {
if (!in_array(getType($cells), ['string', 'array'])) {
throw new InvalidArgumentException('Cells must be a string or a array with plural translations.');
} elseif (is_array($cells)) {
$allowedKeys = ['_', '0', '1'];
- 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 setPluginSelectLanguageRows
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function setPluginSelectLanguageRows($rows) {
if (!in_array(getType($rows), ['string', 'array'])) {
throw new InvalidArgumentException('Rows must be a string or a array with plural translations.');
} elseif (is_array($rows)) {
$allowedKeys = ['_', '0', '1'];
- 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 static::CODE_SUCCESS;