JBZoo\Utils\FS::ext PHP Метод

ext() публичный статический Метод

public static ext ( string $path ) : string
$path string
Результат string
    public static function ext($path)
    {
        if (strpos($path, '?') !== false) {
            $path = preg_replace('#\\?(.*)#', '', $path);
        }
        $ext = pathinfo($path, PATHINFO_EXTENSION);
        $ext = strtolower($ext);
        return $ext;
    }

Usage Example

Пример #1
0
 /**
  * Create asset instance.
  *
  * @param string       $alias
  * @param mixed        $source
  * @param string|array $dependencies
  * @param string|array $options
  * @throws Exception
  * @return Asset
  */
 public function create($alias, $source, $dependencies = [], $options = [])
 {
     $assetType = isset($options['type']) ? $options['type'] : '';
     if (isset($this->_customTypes[$assetType])) {
         $assetType = $this->_customTypes[$assetType];
     } elseif (is_callable($source)) {
         $assetType = 'Callback';
     } elseif (is_string($source)) {
         $ext = strtolower(FS::ext($source));
         if ($ext === 'js') {
             $assetType = 'JsFile';
         } elseif ($ext === 'css') {
             $assetType = 'CssFile';
         } elseif ($ext === 'less') {
             $assetType = 'LessFile';
         } elseif ($ext === 'jsx') {
             $assetType = 'JsxFile';
         }
     } elseif (is_array($source)) {
         $assetType = 'Collection';
     }
     $className = __NAMESPACE__ . '\\Asset\\' . $assetType;
     if (class_exists($className)) {
         $options = is_array($options) ? new Data($options) : $options;
         return new $className($this->getManager(), $alias, $source, $dependencies, $options);
     }
     throw new Exception('Undefined asset type: ' . print_r($source, true));
 }
All Usage Examples Of JBZoo\Utils\FS::ext