Change switch with only 1 check to if
class SomeObject
{
public function run($value)
{
$result = 1;
- switch ($value) {
- case 100:
+ if ($value === 100) {
$result = 1000;
}
return $result;
}
}
Configure your rector.php
:
<?php
use Rector\CodeQuality\Rector\Switch_\SingularSwitchToIfRector;
use Rector\Config\RectorConfig;
return RectorConfig::configure()
->withRules([
SingularSwitchToIfRector::class,
]);