Showing 9 of 330 total issues
Function validate
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
public function validate(array $data)
{
$rules = $this->getRules();
foreach ($rules as $field => $rule) {
if ((isset($rule['required']) && $rule['required'] === true && isset($data[$field]))
- 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 getTranslator
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getTranslator($type, array $params = [])
{
$result = null;
if (!isset($params['language'])) {
Function getTranslator
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function getTranslator($type, array $params = [])
{
$result = null;
if (!isset($params['language'])) {
- 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 getHandlerByPath
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public static function getHandlerByPath($path)
{
$result = null;
$path = self::prepareRoute('/'.trim($path, " /"));
- 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 run
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function run()
{
try {
$this->trigger(self::EVENT_APPLICATION_RUN);
Consider simplifying this complex logical expression. Open
if ((isset($rule['required']) && $rule['required'] === true && isset($data[$field]))
|| ((!isset($rule['required']) || !$rule['required'])) && isset($data[$field])) {
foreach ($rule as $key => $value) {
if ($key !== 'required') {
foreach ($value as $validator) {
Function forceComponentLoading
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function forceComponentLoading()
{
$config = $this->getConfiguration();
foreach ($config[self::COMPONENT_CONFIG_BLOCK] as $key => $params) {
if (isset($params['class']) && isset($params['force'])) {
- 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 translate
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function translate($alias, array $params = [])
{
$result = '';
$translators = $this->getTranslators();
foreach ($translators as $translator) {
- 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 detach
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function detach(Observer $observer, $type = 'default')
{
if (isset($this->observers[$type])) {
foreach ($this->observers[$type] as $key => $obs) {
if ($obs === $observer) {
- 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"