Skip to content

Commit

Permalink
comlexity
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Oct 27, 2021
1 parent 3bda987 commit 7b848a7
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions rules/Php73/Rector/FuncCall/JsonThrowOnErrorRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,7 @@ private function shouldSkip(FuncCall $funcCall): bool
}
}

$firstArg = $funcCall->args[0];
$value = $this->valueResolver->getValue($firstArg->value);
if (is_string($value)) {
return true;
}

if (is_array($value)) {
if ($this->isFirstValueStringOrArray($funcCall)) {
return true;
}

Expand Down Expand Up @@ -151,4 +145,19 @@ private function createConstFetch(string $name): ConstFetch
{
return new ConstFetch(new Name($name));
}

private function isFirstValueStringOrArray(FuncCall $funcCall): bool
{
if (! isset($funcCall->args[0])) {
return false;
}

$firstArg = $funcCall->args[0];
$value = $this->valueResolver->getValue($firstArg->value);
if (is_string($value)) {
return true;
}

return is_array($value);
}
}

0 comments on commit 7b848a7

Please sign in to comment.