もういっちょ細かいとこ

ま、ほんと好みで。
拡張子関係の処理をFileに追加してもいい気がする。
ほぼパス操作なのでFileクラスに機能追加がいいかなぁ。

    public function toClassname($filename, $options = array())
    {
        $doUcfirst = true;
        if (isset($options['ucfirst']) &&
            !is_null($options['ucfirst'])) {
            $doUcfirst = $options['ucfirst'];
        }

        $namespace = '';
        if (isset($options['namespace']) &&
            !is_null($options['namespace'])) {
            $namespace = $options['namespace'];
        }

        $result = null;
        if (!preg_match('|\.php|', $filename)) {
            return $result;
        }

        if ($namespace) {
            $pathname = join('/', preg_split('|_|', $namespace));
            $filename = "{$pathname}/{$filename}";
        }

        $filename = preg_replace('|\.php|', '', $filename);
        $parts = preg_split('|[\\\\/]|', $filename);

        if ($doUcfirst) {
            $result = join('_', array_map('ucfirst', $parts));
        } else {
            $result = strtolower(join('_', $parts));
        }

        return $result;
    }

    public function toClassname($filename, $options = array())
    {
        $f = Maple4_Utils_File::create();
        $ds = DIRECTORY_SEPARATOR;
        $filename = $f->fixDirectorySeparator($filename);

        $doUcfirst = true;
        if (isset($options['ucfirst']) &&
            !is_null($options['ucfirst'])) {
            $doUcfirst = $options['ucfirst'];
        }

        $namespace = '';
        if (isset($options['namespace']) &&
            !is_null($options['namespace'])) {
            $namespace = $options['namespace'];
        }

        $pinfo = pathinfo($filename);
        if (strtolower($pinfo['extension']) != 'php') {
            return null;
        }

        if ($namespace) {
            $paths = explode('_', $namespace);
            $paths[] = $filename;
            $filename = implode($ds, $paths);
        }

        $filename = $pinfo['dirname'] . $ds . basename($pinfo['basename'], '.php'); // $pinfo['filename']
        $parts = explode($ds, $filename);

        $filter = $doUcfirst? 'ucfirst': 'strtolower';
        return join('_', array_map($filter, $parts));
    }