Function processAttributeFilter
has a Cognitive Complexity of 70 (exceeds 5 allowed). Consider refactoring. Open
private static function processAttributeFilter($query, $filter_setting, $filter_requests)
{
$model = (new static());
foreach ($filter_requests as $filter_request) {
// Clean inputs
- 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 getFilterAttributes
has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring. Open
public static function getFilterAttributes($first_call = true)
{
$model = (new static());
if (isset($model->filter_attributes) && is_array($model->filter_attributes)) {
- 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
File ModelTrait.php
has 518 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace Bluora\LaravelDynamicFilter\Traits;
use DB;
Function getAppliedFiltersArray
has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring. Open
public function getAppliedFiltersArray($search_request)
{
$model = (new static());
$result = [];
foreach ($model->getFilterAttributes() as $filter_name => $filter_settings) {
- 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 validateOperators
has 135 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function validateOperators($filter, &$method, &$arguments, $model, $filter_setting, $operator, $value1, $value2)
{
// No space search.
if (array_has($filter_setting, 'phone_search')) {
$value1_numeric = str_replace(' ', '', $value1);
Function validateOperators
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
private static function validateOperators($filter, &$method, &$arguments, $model, $filter_setting, $operator, $value1, $value2)
{
// No space search.
if (array_has($filter_setting, 'phone_search')) {
$value1_numeric = str_replace(' ', '', $value1);
- 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 scopeApplyAttributeFilters
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
public function scopeApplyAttributeFilters($query, $search_request)
{
if (isset($search_request['filters']) && is_array($search_request['filters']) && !empty($search_request['filters'])) {
// Get available filters
- 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 processAttributeFilter
has 77 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function processAttributeFilter($query, $filter_setting, $filter_requests)
{
$model = (new static());
foreach ($filter_requests as $filter_request) {
// Clean inputs
Method getFilterAttributes
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getFilterAttributes($first_call = true)
{
$model = (new static());
if (isset($model->filter_attributes) && is_array($model->filter_attributes)) {
Function scopeModelJoin
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public function scopeModelJoin($query, $relationships, $operator = '=', $type = 'left', $where = false)
{
if (!is_array($relationships)) {
$relationships = [$relationships];
}
- 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 scopeModelJoin
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function scopeModelJoin($query, $relationships, $operator = '=', $type = 'left', $where = false)
{
if (!is_array($relationships)) {
$relationships = [$relationships];
}
Method scopeApplyAttributeFilters
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function scopeApplyAttributeFilters($query, $search_request)
{
if (isset($search_request['filters']) && is_array($search_request['filters']) && !empty($search_request['filters'])) {
// Get available filters
Method getAppliedFiltersArray
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getAppliedFiltersArray($search_request)
{
$model = (new static());
$result = [];
foreach ($model->getFilterAttributes() as $filter_name => $filter_settings) {
Method validateOperators
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
private static function validateOperators($filter, &$method, &$arguments, $model, $filter_setting, $operator, $value1, $value2)
Avoid deeply nested control flow statements. Open
if (in_array($check_operator, $available_operators)) {
$operator = $check_operator;
$value1 = implode(' ', $value1_array);
}
Avoid deeply nested control flow statements. Open
if (isset($settings['name'])) {
$filter_detail['name'] = $settings['name'].': '.$filter_detail['attribute_name'];
}
Method scopeModelJoin
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function scopeModelJoin($query, $relationships, $operator = '=', $type = 'left', $where = false)
Method applyFilterAttributeArray
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
private static function applyFilterAttributeArray($query, $attribute_list, $method, $arguments, $positive = true)
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return false;