Function getFromLocalArray
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
protected function getFromLocalArray($attribute, $lowerRule, $source = null)
{
$source = $source ?: $this->customMessages;
$keys = ["{$attribute}.{$lowerRule}", $lowerRule, $attribute];
- 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 FormatsMessages.php
has 262 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace Illuminate\Validation\Concerns;
use Closure;
Method getMessage
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function getMessage($attribute, $rule)
{
$attributeWithPlaceholders = $attribute;
$attribute = $this->replacePlaceholderInString($attribute);
Method callClassBasedReplacer
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
protected function callClassBasedReplacer($callback, $message, $attribute, $rule, $parameters, $validator)
Method callReplacer
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
protected function callReplacer($message, $attribute, $rule, $parameters, $validator)
Avoid too many return
statements within this method. Open
return (string) $value;
Avoid too many return
statements within this method. Open
return $this->getFromLocalArray(
$attribute, $lowerRule, $this->fallbackMessages
) ?: $key;
Avoid too many return
statements within this method. Open
return 'empty';
Function getDisplayableAttribute
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function getDisplayableAttribute($attribute)
{
$primaryAttribute = $this->getPrimaryAttribute($attribute);
$expectedAttributes = $attribute != $primaryAttribute
- 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 replaceIndexOrPositionPlaceholder
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function replaceIndexOrPositionPlaceholder($message, $attribute, $placeholder, Closure $modifier = null)
{
$segments = explode('.', $attribute);
$modifier ??= fn ($value) => $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"