Skip to content

Commit

Permalink
PHP-CS-Fixer#7968 remove switch statement
Browse files Browse the repository at this point in the history
  • Loading branch information
krzysztof-ciszewski committed May 11, 2024
1 parent 9850e41 commit f84f505
Showing 1 changed file with 18 additions and 32 deletions.
50 changes: 18 additions & 32 deletions src/Fixer/PhpUnit/PhpUnitDedicateAssertFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -723,38 +723,24 @@ private function fixAssertNewNames(Tokens $tokens, array $assertCall): void
return;
}

switch ($assertCall['loweredName']) {
case 'assertnotisreadable':
$tokens[$assertCall['index']] = new Token([
T_STRING,
'assertIsNotReadable',
]);

break;

case 'assertnotiswritable':
$tokens[$assertCall['index']] = new Token([
T_STRING,
'assertIsNotWritable',
]);

break;

case 'assertdirectorynotexists':
$tokens[$assertCall['index']] = new Token([
T_STRING,
'assertDirectoryDoesNotExist',
]);

break;

case 'assertfilenotexists':
$tokens[$assertCall['index']] = new Token([
T_STRING,
'assertFileDoesNotExist',
]);

break;
$replacement = null;
if ('assertnotisreadable' === $assertCall['loweredName']) {
$replacement = 'assertIsNotReadable';
} elseif ('assertnotiswritable' === $assertCall['loweredName']) {
$replacement = 'assertIsNotWritable';
} elseif ('assertdirectorynotexists' === $assertCall['loweredName']) {
$replacement = 'assertDirectoryDoesNotExist';
} elseif ('assertfilenotexists' === $assertCall['loweredName']) {
$replacement = 'assertFileDoesNotExist';
}

if (null === $replacement) {
return;
}

$tokens[$assertCall['index']] = new Token([
T_STRING,
$replacement,
]);
}
}

0 comments on commit f84f505

Please sign in to comment.