Skip to content

Commit

Permalink
Minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Slamdunk committed Jul 9, 2018
1 parent 66f6bd9 commit 9389def
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/Fixer/PhpUnit/PhpUnitMethodCasingFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,8 @@ private function updateMethodCasing($functionName)
{
if (self::CAMEL_CASE === $this->configuration['case']) {
$newFunctionName = $functionName;
$newFunctionName = str_replace('_', ' ', $newFunctionName);
$newFunctionName = ucwords($newFunctionName);
$newFunctionName = str_replace(' ', '', $newFunctionName);
$newFunctionName = ucwords($newFunctionName, '_');
$newFunctionName = str_replace('_', '', $newFunctionName);
$newFunctionName = lcfirst($newFunctionName);
} else {
$newFunctionName = Utils::camelCaseToUnderscore($functionName);
Expand All @@ -152,7 +151,7 @@ private function updateMethodCasing($functionName)

/**
* @param Tokens $tokens
* @param int$index
* @param int $index
*
* @return bool
*/
Expand All @@ -163,14 +162,14 @@ private function isTestMethod(Tokens $tokens, $index)
return false;
}

// if the function name starts with test its a test
// if the function name starts with test it's a test
$functionNameIndex = $tokens->getNextMeaningfulToken($index);
$functionName = $tokens[$functionNameIndex]->getContent();

if ($this->startsWith('test', $functionName)) {
return true;
}
// If the function doesn't have test in its name, and no doc block, its not a test
// If the function doesn't have test in its name, and no doc block, it's not a test
if (!$this->hasDocBlock($tokens, $index)) {
return false;
}
Expand Down Expand Up @@ -205,9 +204,7 @@ private function isMethod(Tokens $tokens, $index)
*/
private function startsWith($needle, $haystack)
{
$len = strlen($needle);

return substr($haystack, 0, $len) === $needle;
return substr($haystack, 0, strlen($needle)) === $needle;
}

/**
Expand Down

0 comments on commit 9389def

Please sign in to comment.