Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
23 lines (16 sloc) 223 Bytes
<?php
#bad
if($what == 'a'){
$this->aa();
}elseif($what == 'b'){
$this->bb();
}else{
$this->otherwise();
}
#good
$map = [
'a' => 'aa',
'b' => 'bb'
];
$method = $map[$what] ?? 'otherwise';
$this->$method();
You can’t perform that action at this time.