if (isset($this->directory
)) { return $segments;
} // Loop through our segments and return as soon as a controller
// is found or when such a directory doesn't exist
$c =
count($segments);
while ($c-- > 0
) { $segmentConvert =
ucfirst($this->translateURIDashes === true ?
str_replace('-', '_',
$segments[0
]) :
$segments[0
]);
// as soon as we encounter any segment that is not PSR-4 compliant, stop searching
if (!
$this->
isValidSegment($segmentConvert)) { return $segments;
} $test = APPPATH . 'Controllers/' .
$this->directory .
$segmentConvert;
// as long as each segment is *not* a controller file but does match a directory, add it to $this->directory
if (!
is_file($test . '.php'
) &&
is_dir($test)) { $this->
setDirectory($segmentConvert, true, false
);
array_shift($segments);
continue;
}