当前位置: 首页>>代码示例>>PHP>>正文


PHP SplFileInfo::getExtension方法代码示例

本文整理汇总了PHP中Symfony\Component\Finder\SplFileInfo::getExtension方法的典型用法代码示例。如果您正苦于以下问题:PHP SplFileInfo::getExtension方法的具体用法?PHP SplFileInfo::getExtension怎么用?PHP SplFileInfo::getExtension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Finder\SplFileInfo的用法示例。


在下文中一共展示了SplFileInfo::getExtension方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * Create sprite image data holder
  * @param string $path
  * @param SplFileInfo $fileInfo
  */
 public function __construct($path, SplFileInfo $fileInfo)
 {
     $this->basePath = $path;
     $this->info = $fileInfo;
     // Assign fileinfo variables
     $this->path = $this->info->getPathname();
     $this->size = $this->info->getSize();
     // Assign image data
     $info = getimagesize($this->path);
     if (!is_array($info)) {
         throw new UnexpectedValueException("The image '{$this->path}' is not a correct image format.");
     }
     $this->hash = sha1(file_get_contents($this->getFullPath()));
     $this->width = (int) $info[0];
     $this->height = (int) $info[1];
     $this->mime = $info['mime'];
     $this->type = explode('/', $this->mime)[1];
     // Assign css name
     $ext = $this->info->getExtension();
     // Replace path parts with `-`
     $name = str_replace(['/', '\\', '_'], '-', $this->info->getRelativePathname());
     // Remove leading `-`
     $name = preg_replace('~^-*~', '', $name);
     // Remove double dashes
     $name = preg_replace('~-+~', '-', $name);
     // Remove file extension
     $name = preg_replace("~\\.{$ext}\$~", '', $name);
     // Replace dots with -
     $name = preg_replace('~\\.~', '-', $name);
     $this->name = $name;
 }
开发者ID:maslosoft,项目名称:sprite,代码行数:36,代码来源:SpriteImage.php

示例2: getFileContents

 /**
  * @param SplFileInfo $file
  *
  * @return string
  */
 private function getFileContents(SplFileInfo $file)
 {
     $content = $file->getContents();
     if ($file->getExtension() === 'js' && substr($content, -1) !== ';') {
         $content .= ';';
     }
     return $content;
 }
开发者ID:bldr-io,项目名称:frontend-block,代码行数:13,代码来源:ConcatTask.php

示例3: getDirectoryPrettyName

 /**
  * Generate directory path to be used for the file pretty name.
  *
  * @return string
  */
 protected function getDirectoryPrettyName()
 {
     $fileBaseName = $this->getFileName();
     $fileRelativePath = $this->normalizePath($this->file->getRelativePath());
     if (in_array($this->file->getExtension(), ['php', 'md']) && $fileBaseName != 'index') {
         $fileRelativePath .= $fileRelativePath ? "/{$fileBaseName}" : $fileBaseName;
     }
     return ORCA_PUBLIC_DIR . ($fileRelativePath ? "/{$fileRelativePath}" : '');
 }
开发者ID:tao,项目名称:orca,代码行数:14,代码来源:BaseHandler.php

示例4: checkIfImage

 public static function checkIfImage($path)
 {
     $file = new \SplFileInfo($path);
     $ex = $file->getExtension();
     if ($ex === "png" || $ex === "gif" || $ex === 'bmp' || $ex === "jpeg" || $ex === "jpg") {
         return true;
     }
     return false;
 }
开发者ID:VertexDezign,项目名称:VertexDezign,代码行数:9,代码来源:Media.php

示例5: transform

 /**
  * Transform a taxonomy YAML into a TaxonomyFile object
  *
  * @param SplFileInfo $file
  *
  * @return \Skimpy\Contracts\Entity|TaxonomyFile
  */
 public function transform(SplFileInfo $file)
 {
     $data = $this->parser->parse($file->getContents());
     $missingFields = $this->getMissingFields($data);
     if (false === empty($missingFields)) {
         throw new TransformationFailure(sprintf('Missing required fields (%s) in taxonomy file: %s', implode(', ', $this->getMissingFields($data)), $file->getRealPath()));
     }
     $filename = $file->getFilename();
     $ext = $file->getExtension();
     $slug = explode('.' . $ext, $filename)[0];
     return new TaxonomyFile($slug, $data['name'], $data['plural_name'], $data['terms']);
 }
开发者ID:jtallant,项目名称:skimpy-engine,代码行数:19,代码来源:FileToTaxonomyFile.php

示例6: isBinary

 private function isBinary(SplFileInfo $file)
 {
     $ext = $file->getExtension();
     return false === in_array($ext, $this->params['text_extensions']);
 }
开发者ID:jjk-jacky,项目名称:Spress,代码行数:5,代码来源:FilesystemDataSource.php

示例7: getFilename

 /**
  * Returns filename w/o extension
  *
  * @return string
  */
 public function getFilename()
 {
     $exclude = '.' . $this->file->getExtension();
     return $this->file->getBasename($exclude);
 }
开发者ID:jtallant,项目名称:skimpy-engine,代码行数:10,代码来源:ContentFile.php

示例8: getClassname

 /**
  * Gets the class name.
  *
  * @param \Symfony\Component\Finder\SplFileInfo $file
  *
  * @return string
  */
 protected function getClassname(SplFileInfo $file)
 {
     if ($file->getExtension() === 'php') {
         return $file->getBasename('.php');
     }
     if ($file->getFilename() === $this->composerFilename) {
         $composerData = $this->readComposerFile($file);
         if (isset($composerData['extra']['spress_class']) === true && is_string($composerData['extra']['spress_class'])) {
             return $composerData['extra']['spress_class'];
         }
     }
     return '';
 }
开发者ID:jjk-jacky,项目名称:Spress,代码行数:20,代码来源:PluginManagerBuilder.php

示例9: setTarget

 /**
  * Determine the target path.
  *
  * @param  SplFileInfo $file
  * @return string
  */
 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;
 }
开发者ID:torann,项目名称:skosh-generator,代码行数:22,代码来源:Content.php

示例10: getPath

 /**
  * @param \Symfony\Component\Finder\SplFileInfo $file
  *
  * @return string
  */
 private function getPath(SplFileInfo $file)
 {
     switch ($file->getExtension()) {
         case 'gz':
             $path = 'compress.zlib://' . $file->getPathname();
             break;
         case 'bz2':
             $path = 'compress.bzip2://' . $file->getPathname();
             break;
         default:
             $path = $file->getPathname();
             break;
     }
     return $path;
 }
开发者ID:browscap,项目名称:browscap-php,代码行数:20,代码来源:LogfileCommand.php

示例11: getExtension

 public function getExtension()
 {
     return $this->fileInfo->getExtension();
 }
开发者ID:phramz,项目名称:doctrine-annotation-scanner,代码行数:4,代码来源:ClassFileInfo.php

示例12: fromFile

 /**
  * Добавляет в загрузку один файл
  *
  * @param string $pathToFile путь к файлу из которого необходимо загрузить фикстуры
  *
  * @return $this
  * @throws \InvalidArgumentException
  */
 public function fromFile($pathToFile)
 {
     if (empty($pathToFile)) {
         throw new \InvalidArgumentException("Был передан пустой путь к файлу с фикстурами");
     }
     if (!is_string($pathToFile)) {
         throw new \InvalidArgumentException("Параметр pathToFile не является строкой");
     }
     if (!file_exists($pathToFile)) {
         throw new \InvalidArgumentException("Был передан несуществующий путь к файлу '{$pathToFile}'");
     }
     $fileInfo = new \SplFileInfo($pathToFile);
     if ($fileInfo->getExtension() !== self::DEFAULT_FILE_EXTENSION) {
         throw new \InvalidArgumentException("Переданный файл '{$pathToFile}' обладает неправильным расширением");
     }
     $this->filePathsByKey[$fileInfo->getRealPath()] = true;
     return $this;
 }
开发者ID:amstaffix,项目名称:alice-fixtures-smart-loader,代码行数:26,代码来源:FixturesLoader.php

示例13: shouldIgnore

 /**
  * @param SplFileInfo $file
  * @return bool
  */
 protected function shouldIgnore(SplFileInfo $file)
 {
     if ($file->getExtension() === 'php') {
         return true;
     }
     return false;
 }
开发者ID:mediamonks,项目名称:composer-vendor-cleaner,代码行数:11,代码来源:AbstractHandler.php

示例14: extractStringTokens

 /**
  * Extract all strings from a given file.
  *
  * @param SplFileInfo $file
  *
  * @return string[]
  */
 protected function extractStringTokens(SplFileInfo $file)
 {
     // Fetch tokens from cache if available
     $hash = 'janitor.tokens.' . md5($file->getPathname()) . '-' . $file->getMTime();
     return $this->cache->rememberForever($hash, function () use($file) {
         $contents = $file->getContents();
         // See if we have an available Tokenizer
         // and use it to extract the contents
         switch ($file->getExtension()) {
             case 'php':
                 $tokenizer = strpos($file->getBasename(), 'blade.php') !== false ? new BladeTokenizer() : new PhpTokenizer();
                 break;
             case 'twig':
                 $tokenizer = new TwigTokenizer();
                 break;
             case 'json':
                 $tokenizer = new JsonTokenizer();
                 break;
             case 'yml':
             case 'yaml':
                 $tokenizer = new YamlTokenizer();
                 break;
             case 'xml':
                 $tokenizer = new XmlTokenizer();
                 break;
             default:
                 $tokenizer = new DefaultTokenizer();
                 break;
         }
         return $tokenizer->tokenize($contents);
     });
 }
开发者ID:anahkiasen,项目名称:janitor,代码行数:39,代码来源:Codebase.php

示例15: _isSkip

 /**
  * Check skip files.
  *
  * @param SplFileInfo $file
  * @return bool
  */
 protected function _isSkip(SplFileInfo $file)
 {
     $name = $file->getFilename();
     $ext = $file->getExtension();
     return Arr::in($ext, $this->_skipFileExt) || Arr::in($name, $this->_skipFileNames);
 }
开发者ID:UnionCMS,项目名称:Core,代码行数:12,代码来源:CodeStyle.php


注:本文中的Symfony\Component\Finder\SplFileInfo::getExtension方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。