prepare seed classname

@param \Symfony\Component\Finder\SplFileInfo $file
@return String
547642
protected function prepareSeedClass($file)
    {
        $extension = $file->getExtension();
        if ($extension !== 'php') {
            return null;
        }
        return '\\' . str_replace('.' . $extension, '', $file->getFilename());
    }
1335399
protected function setTarget(SplFileInfo $file)
    {
        // Page extension
        $ext = $file->getExtension();

        // Twig templates are HTML
        if (!$this->has('template') || $this->get('template') === 'none') {
            $targetExt = $ext;
        }
        else {
            $targetExt = 'html';
        }

        // Get clean source path
        $sourcePath = $this->getCleanPath($file->getRelativePathName());

        // Replace source extension with that of the template
        $this->target = substr($sourcePath, 0, -strlen($ext));
        $this->target .= $targetExt;
    }
1306587
private function getConfigurationNesting(SplFileInfo $file)
    {
        $directory = $this->normalizePath(dirname($file->getRealPath()));
        $directory = ltrim($directory, $this->userConfigurationPath);

        if ($tree = trim(str_replace(config_path(), '', $directory), DIRECTORY_SEPARATOR))
        {
            $tree = str_replace(DIRECTORY_SEPARATOR, '.', $tree).'.';
        }

        return $tree;
    }
982468
private function getClassByToken($file)
    {

        if (false === file_exists($file)) {
            throw new FileNotFoundException(sprintf("File %s is not readable or not exist", $file));
        }

        $fp = fopen($file, 'r');

        $class = $namespace = $buffer = '';
        $i     = 0;

        while (!$class) {

            if (feof($fp)) {
                break;
            }

            $buffer .= fread($fp, 512);
            $tokens = token_get_all($buffer);

            if (strpos($buffer, '{') === false) {
                continue;
            }

            list($namespace, $class) = $this->loopToken($i, $tokens, $namespace);
        }

        if ($namespace == '') {
            return $class;
        }

        return sprintf("%s\\%s", $namespace, $class);
    }
859657
private function _getClassFiles($file)
    {
        $classes = array();
        $namespace = 0;
        $tokens = token_get_all(file_get_contents($file));
        $count = count($tokens);
        $dlm = false;
        for ($i = 2; $i < $count; $i++) {
            if ((isset($tokens[$i - 2][1]) && ($tokens[$i - 2][1] == "phpnamespace" || $tokens[$i - 2][1] == "namespace")) ||
                ($dlm && $tokens[$i - 1][0] == T_NS_SEPARATOR && $tokens[$i][0] == T_STRING)) {
                    if (!$dlm) $namespace = 0;
                    if (isset($tokens[$i][1])) {
                        $namespace = $namespace ? $namespace . "\\" . $tokens[$i][1] : $tokens[$i][1];
                        $dlm = true;
                    }
                } elseif ($dlm && ($tokens[$i][0] != T_NS_SEPARATOR) && ($tokens[$i][0] != T_STRING)) {
                $dlm = false;
            }
            if (($tokens[$i - 2][0] == T_CLASS || (isset($tokens[$i - 2][1]) && $tokens[$i - 2][1] == "phpclass"))
                && $tokens[$i - 1][0] == T_WHITESPACE && $tokens[$i][0] == T_STRING) {
                    $class_name = $tokens[$i][1];
                    if (!isset($classes[$namespace])) $classes[$namespace] = array();
                    $classes[$namespace][] = $class_name;
                }
        }

        return $classes;

    }
1300809
public function santitizeFileNames($file)
    {
        $path           = pathinfo($file['name']);
        $new_filename   = preg_replace('/.' . $path['extension'] . '$/', '', $file['name']);
        $file['name']   = $this->localLetterSanitize(sanitize_title($new_filename)) . '.' . $path['extension'];
        return $file;
    }
123405
protected function mapFileInfo(SplFileInfo $file)
    {
        $normalized = [
            'type' => $file->getType(),
            'path' => $this->getFilePath($file),
        ];

        $normalized['timestamp'] = $file->getMTime();

        if ($normalized['type'] === 'file') {
            $normalized['size'] = $file->getSize();
        }

        return $normalized;
    }
260840
private function getBundleClass(SplFileInfo $fileInfo)
    {
        $reflection = new ReflectionFile($fileInfo->getRealPath());
        $baseName   = $fileInfo->getBasename('.php');
        
        foreach ($reflection->getNamespaces() as $namespace) {
            return $namespace . '\\' . $baseName;
        }
        
        return null;
    }
677628
protected function processFile(SplFileInfo $file): array
    {
        $realPath = $file->getRealPath();
        if ($this->output->isDebug()) {
            $this->output->writeln('Process file: ' . $realPath);
        }

        if ($realPath === false) {
            throw new RuntimeException(sprintf('File not found: %s', $file));
        }

        $processor = new FileProcessor($realPath);
        $check = new FileCheck();

        if (!$this->skipClasses) {
            $check->processFileClasses($processor->getClasses(), $realPath);
        }

        if (!$this->skipMethods) {
            $check->processFileMethods($processor->getMethods(), $realPath);
        }

        if (!$this->skipSignatures) {
            $check->processFileSignatues($processor->getMethods(), $realPath);
        }

        foreach ($check->getErrors() as $errorItem) {
            if ($this->output->isDebug()) {
                $this->output->writeln('Error in line: ' . var_export($errorItem, true));
            }
            $this->errors[] = $errorItem;
        }

        foreach ($check->getWarnings() as $warningEntry) {
            if ($this->output->isDebug()) {
                $this->output->writeln('Warning in line: ' . var_export($warningEntry, true));
            }
            $this->warnings[] = $warningEntry;
        }

        $hasErrors = !empty($errorItem);
        $hasWarnings = !empty($warningEntry);

        if (!$hasErrors) {
            $this->passed++;
        }

        return [$hasErrors, $hasWarnings];
    }
1129569
protected function getFilePieces(\SplFileInfo $file)
    {
        $key = $file->getBasename();
        if (!array_key_exists($key, $this->filePieces)) {
            $pieces = explode('.', $file->getBasename());
            if (count($pieces) < 3) {
                return true;
            }
            $extension = array_pop($pieces);
            $locale = array_pop($pieces);
            $domain = implode('.', $pieces);

            $this->filePieces[$key] = [
                self::FILE_PIECE_DOMAIN => $domain,
                self::FILE_PIECE_LOCALE => $locale,
                self::FILE_PIECE_EXTENSION => $extension,
            ];
        }

        return $this->filePieces[$key];
    }
540001
public static function getFormat(SplFileInfo $file)
    {
        $name = $file->getRelativePathname();
        $ext  = substr($name, strrpos($name, '.') + 1);

        switch ($ext) {
            case 'md':
                return 'markdown';

            case 'yml':
                return 'yaml';

            default:
                return $ext;
        }
    }
581053
public function clean(SplFileInfo $file)
    {
        $name = $file->getFilename();
        if ($file->isFile()) {
            $name = pathinfo($name, PATHINFO_FILENAME);
        }

        $name = str_replace("\t\n\r\0\x0B", ' ', $name); // remove control characters
        $name = str_replace('_', ' ', $name);

        $name = preg_replace('/\[[^\[\]]*\]/', ' ', $name); // remove [...]
        $name = preg_replace('/\([^\(\)]*\)/', ' ', $name); // remove (...)

        // remove all file meta data
        $reg = sprintf('/[ .,](?:%s)[ .,]/i', implode('|', $this->meta));
        while (preg_match($reg, $name.' ')) {
            $name = preg_replace($reg, ' ', $name.' ');
        }

        $name = str_replace('  ', ' ', $name); // remove double spaces
        $name = trim($name, ' .,-');

        return $name;
    }
1070192
private function convertResource(Resource $resource, \SplFileInfo $file)
    {
        return new Resource(
            array_merge(
                $resource->getMetadata(),
                [
                    'file' => $file->getRealpath(),
                ]
            ),
            $resource->getMetadata('type')
        );
    }
615444
protected function parseArchive(\SplFileInfo $file): \SplFileInfo
    {
        $archive = (new ZipFile())->openFile(
            $file instanceof \SplTempFileObject ? $this->generateTempFile($file) : $file->getRealPath()
        );
        $this->correctArchiveFilenamesEncoding($archive);
        $this->flattenArchive($archive);
        $this->filenames = $this->correctArchiveFilenames($archive);
        
        $tempDirectoryPath = (new GenericDictionaryParser())->generateTempDirectory();
        $archive->extractTo($tempDirectoryPath);
        $archive->close();

        $validator = new \esperecyan\dictionary_php\Validator();
        $validator->setLogger($this->logger);
        foreach (new \FilesystemIterator(
            $tempDirectoryPath,
            \FilesystemIterator::KEY_AS_FILENAME
        ) as $filename => $file) {
            if ($file->getExtension() === 'txt') {
                if (isset($quizFile)) {
                    throw new SyntaxException(_('拡張子が「.txt」のファイルが2つ以上含まれています。'));
                }
                if (!in_array(
                    (new Finfo(FILEINFO_MIME_TYPE))->file($file),
                    ['text/plain', 'text/csv']
                )) {
                    throw new SyntaxException(
                        sprintf(_('「%s」は通常のテキストファイルとして認識できません。'), $filename)
                    );
                }
                $quizFile = $file;
            }
        }

        if (empty($quizFile)) {
            throw new SyntaxException(_('拡張子が「.txt」のファイルが見つかりません。'));
        }
        
        return $quizFile;
    }
1349635
protected function removeHeader(\SplFileInfo $file)
	{
		$content = file_get_contents($file->getRealPath());

		$lines = explode(PHP_EOL, $content);

		foreach ($lines as $i => $l)
		{
			$l = trim($l);

			if (strpos($l, "<?php") === 0 || $l == "")
			{
				continue;
			}

			if (strpos($l, "/**") !== false || strpos($l, "*") !== false || strpos($l, "*/") !== false)
			{
				unset($lines[$i]);

				continue;
			}

			break;
		}

		file_put_contents($file->getRealPath(), implode(PHP_EOL, $lines));
	}
508214
protected function isAllowFile(SplFileInfo $file)
    {
        return in_array(strtolower(pathinfo($file->getFilename(), PATHINFO_EXTENSION)), $this->allow_ext);
    }
860550
public function getMimeType(\SplFileInfo $file)
    {
        $fileInfo = finfo_open(FILEINFO_MIME_TYPE);
        $mimeType = finfo_file($fileInfo, $file->getPathname());
        finfo_close($fileInfo);

        return $mimeType;
    }