Get a migration class name by a migration file name.

@param string $file

@return string
970812
protected function getMigrationClassNameByFileName($file)
    {
        $fileExploded = explode('_', $file);

        $datePart = implode('_', array_slice($fileExploded, 0, 5));
        $namePart = implode('_', array_slice($fileExploded, 5));

        return Helpers::studly($namePart.'_'.$datePart);
    }
982572
protected function getType($file)
    {
        $extension = $file->ext();
        if (isset($this->typeMap[$extension])) {
            return $this->typeMap[$extension];
        }

        return $file->mime() ?: 'application/octet-stream';
    }
1288609
public static function getClassesFromFile($file)
    {
        $php = \File::get($file);
        $classes = array();
        $tokens = token_get_all($php);
        $count = count($tokens);
        for ($i = 2; $i < $count; $i++) {
            if ($tokens[$i - 2][0] == T_CLASS
                && $tokens[$i - 1][0] == T_WHITESPACE
                && $tokens[$i][0] == T_STRING
            ) {
                $class_name = $tokens[$i][1];
                $namespace = self::getNamespace($tokens);
                $classes[] = $namespace . "\\" . $class_name;
            }
        }
        return $classes;
    }
1294708
public static function getMimeType($file)
    {
        $finfo = finfo_open(FILEINFO_MIME_TYPE);
        $type = finfo_file($finfo, $file);
        finfo_close($finfo);

        return $type;
    }
547642
protected function prepareSeedClass($file)
    {
        $extension = $file->getExtension();
        if ($extension !== 'php') {
            return null;
        }
        return '\\' . str_replace('.' . $extension, '', $file->getFilename());
    }
1138282
public static function _getFilename ($file)
	{
		
		// Remove extension
		
		$base	= basename ($file);
		$arr	= explode ('.', $base);
		array_pop ($arr);
		
		// Reset the filename
		
		$file	= NULL;
		
		// Construct the filename without the extension
		
		foreach ($arr as $part)
		{
			$file	.= $part;
		}
		
		// Return the filename
		
		return $file;
		
	}
210444
protected function parseConfig($file)
    {
        $namespace = '';
        $directory = '';

        $config = file_get_contents($file);
        switch (pathinfo($file, PATHINFO_EXTENSION)) {
            case 'yml':
            case 'yaml':
                $config = Yaml::parse($config);
                if (isset($config['migrations_namespace'])) {
                    $namespace = $config['migrations_namespace'];
                }
                if (isset($config['migrations_directory'])) {
                    $directory = $config['migrations_directory'];
                }
                break;
            case 'xml':
                $doc = new \DOMDocument();
                $doc->loadXML($config);
                $list = $doc->getElementsByTagName('migrations-namespace');
                if ($list->length) {
                    $namespace = $list->item(0)->nodeValue;
                }
                $list = $doc->getElementsByTagName('migrations-directory');
                if ($list->length) {
                    $directory = $list->item(0)->nodeValue;
                }
                break;
        }

        return [
            'namespace' => $namespace && $namespace[0] == '\\' ? substr($namespace, 1) : $namespace,
            'directory' => $directory,
        ];
    }
1202644
public static function get_name($file, $ext = false) {
        $name = trim($file['name']);
        $name = str_replace(' ', '', $name);
        $name = str_replace('　', '', $name);
        if ($ext) {
            return $name;
        }
        $pos = strrpos($name, '.');
        if ($pos === false) {
            return $name;
        }
        return trim(substr($name, 0, $pos));
    }
510924
public static function getMimetype(string $file): string
    {
        $finfo = finfo_open(FILEINFO_MIME_TYPE); // return mime type ala mimetype extension
        $mimetype = finfo_file($finfo, $file);
        finfo_close($finfo);
        
        return $mimetype;
    }
1047321
public static function loadClassFile($file) {
		$before = array_merge(get_declared_classes(), get_declared_interfaces());
		require_once $file;
		$after = array_merge(get_declared_classes(), get_declared_interfaces());

		$diff = array_diff($after, $before);

		#class was maybe already loaded
		if(!$diff) {
			foreach(array_merge(get_declared_classes(), get_declared_interfaces()) as $class) {
				$reflector = new \ReflectionClass($class);
				if($reflector->getFileName() == realpath($file)) {
					$result = $class;
					break;
				}
			}
			if(!isset($result))
				throw new \Exception('File '.$file.' does not contain any class.');
		}
		else
			$result = array_values($diff)[count($diff)-1];

		return $result;
	}
303831
private function getClassForFile($file)
    {
        // Open a file pointer to the file
        $fp = fopen($file, 'r');

        // Initialise some variables
        $class = $namespace = $buffer = '';
        $i     = 0;

        // Loop through each line of the file until a class is found
        while (!$class) {
            // If we reach the end of the file then exit the loop
            if (feof($fp)) {
                break;
            }

            // Read a portion from the file and append it to the buffer
            $buffer .= fread($fp, 512);

            // Scan the file for tokens
            //
            // We suppress errors here, as we expect errors because we are
            // only parsing a portion of the file at a time
            $tokens = @token_get_all($buffer);

            // Don't bother trying to parse the output until we
            // can see an opening curly brace
            if (strpos($buffer, '{') === false) {
                continue;
            }

            // Loop through each of the found tokens
            for (;$i < count($tokens);$i++) {
                // Check if the namespace keyword has been found yet
                if ($tokens[$i][0] === T_NAMESPACE) {
                    // Continue looping through the found tokens
                    for ($j = $i + 1;$j < count($tokens); $j++) {
                        // A string immediately after the namespace keyword
                        // is the name of the namespace
                        if ($tokens[$j][0] === T_STRING) {
                            // Add each section of the namespace to
                            // our predefined variable
                            $namespace .= '\\'.$tokens[$j][1];
                        } elseif ($tokens[$j] === '{' || $tokens[$j] === ';') {
                            // If we reach a curly brace or a semicolon
                            // we've got the full namespace
                            break;
                        }
                    }
                }

                // Check if the class keyword has been found yet
                if ($tokens[$i][0] === T_CLASS) {
                    // Continue looping through the found tokens
                    for ($j = $i + 1;$j < count($tokens);$j++) {
                        // When we reach the curly brace, store the
                        // class name in the predefined variable
                        if ($tokens[$j] === '{') {
                            $class = $tokens[$i + 2][1];
                        }
                    }
                }
            }
        }

        // If no class is found, return null
        if (!$class) {
            return;
        }

        // Return the fully-qualified class name
        return Str::namespaced("$namespace\\$class");
    }
350031
private function getManifestFileName($file)
    {
        if (!isset($this->metaCache[$file])) {
            $ds = DIRECTORY_SEPARATOR;
            $base = sha1_file($file) . '_'.basename($file) . '.manifest';
            $name = substr_replace(substr_replace($base, $ds, 4, 0), $ds, 2, 0);

            $this->metaCache[$file] = sprintf('%s%s%s', $this->manifest, $ds, $name);
        }

        return $this->metaCache[$file];
    }
871239
protected function extractFileName($file)
    {
        if ($file instanceof UploadedFile) {
            return $file->tempName;
        } elseif (is_string($file)) {
            if (file_exists($file)) {
                return $file;
            }
            throw new InvalidParamException("File '{$file}' does not exist.");
        }

        throw new InvalidParamException('Unsupported type of "file" attribute.');
    }
111769
protected static function getTypeFinfoExt($file) {

		$type = (new \finfo(FILEINFO_MIME_TYPE))->file($file);

		if($type) {
			return $type;
		}

		else {
			return self::getTypeFileExtList($file);
		}

	}
836432
protected function getTypeByFile($file)
  {
    switch (strtolower(pathinfo($file, PATHINFO_EXTENSION))) {
      case 'jpg':
      case 'jpeg':
        $type = IMG_JPG;
        break;
      case 'png':
        $type = IMG_PNG;
        break;
      case 'gif':
        $type = IMG_GIF;
        break;
      default:
        $type = false;
    }

    return $type;
  }
1006014
public function getClassName(SplFileInfo $file): string
    {
        return
            rtrim($this->getRootNamespace(), '\\') .
            str_replace('/', '\\', str_replace($this->getAppPath(), '', $file->getPath())) .
            '\\' .
            $file->getBasename('.' . $file->getExtension())
        ;
    }
701678
public function getBindingForFile( $file ) {
		$engine_key = $this->default;

		foreach ( $this->bindings as $suffix => $engine ) {
			if ( substr( $file, -strlen( $suffix ) ) === $suffix ) {
				$engine_key = $engine;
				break;
			}
		}

		return $engine_key;
	}