This is intended to be more of a discussion than an outright question, hence I've made it community wiki. When do you choose to break a method into smaller methods.
Say I have a method that has one purpose, i.e. to load a configuration file
public function configure($file){
$info = path_info(file);
$ext = $info['extension'];
switch($ext){
case 'ini':
//code to parse ini files
break;
case 'xml':
//code to parse xml files
break;
case 'php':
//code to parse php files
break;
}
}
personally, I'd break out to internal methods depending on the outcome of the switch - but say I have a more sequential method, a series of steps - i.e.
public function doSequence(){
$stepOne = //some database access to retrieve values
$stepTwo = //the result of some interpretation of values
$stepThree = //a fresh database interaction based on the interpreted values
$stepFour = //prep values for return
return $values
}
So, what is your guiding principle for refactoring methods into the appropriate level of granularity?