Skip to content

Commit

Permalink
infection#654 remove getFunctionName fx
Browse files Browse the repository at this point in the history
  • Loading branch information
majkel89 committed Mar 28, 2019
1 parent cacb538 commit 3b486ca
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/Mutator/Extensions/MBString.php
Expand Up @@ -57,16 +57,22 @@ public function __construct(MutatorConfig $config)
}

/**
* @param Node\Expr\FuncCall $node
*
* @return Node|Node[]|Generator
*/
public function mutate(Node $node)
{
yield from $this->converters[$this->getFunctionName($node)]($node);
yield from $this->converters[$node->name->toLowerString()]($node);
}

protected function mutatesNode(Node $node): bool
{
return isset($this->converters[$this->getFunctionName($node)]);
if (!$node instanceof Node\Expr\FuncCall || !$node->name instanceof Node\Name) {
return false;
}

return isset($this->converters[$node->name->toLowerString()]);
}

private function setupConverters(array $functionsMap): void
Expand Down Expand Up @@ -179,15 +185,6 @@ private function isInMbCaseMode(int $mode, string ...$cases): bool
return false;
}

private function getFunctionName(Node $node): ?string
{
if (!$node instanceof Node\Expr\FuncCall || !$node->name instanceof Node\Name) {
return null;
}

return $node->name->toLowerString();
}

private function mapFunctionCall(Node\Expr\FuncCall $node, string $newFuncName, array $args): Node\Expr\FuncCall
{
return new Node\Expr\FuncCall(
Expand Down

0 comments on commit 3b486ca

Please sign in to comment.