Skip to content

RC4 - filename optimization #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 20, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions src/Container/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ class File
const TYPE_SASS = 'sass';
const TYPE_COMPASS = 'compass';
const TYPE_LESS = 'less';
const TYPE_UNKNOWN = 'unknown';
/**
* @var string[]
*/
private static $extensions = [
self::TYPE_SCSS,
self::TYPE_SASS,
self::TYPE_COMPASS,
self::TYPE_LESS,
];
/**
* @var string
*/
Expand Down Expand Up @@ -157,21 +167,11 @@ public function setType($type)
*/
private function detectSourceTypeFromPath($path)
{
switch (true) {
case 0 !== preg_match('/^.*\.' . static::TYPE_SCSS . '/', $path):
$this->type = static::TYPE_SCSS;
break;
case 0 !== preg_match('/^.*\.' . static::TYPE_SASS . '/', $path):
$this->type = static::TYPE_SASS;
break;
case 0 !== preg_match('/^.*\.' . static::TYPE_COMPASS . '/', $path):
$this->type = static::TYPE_COMPASS;
break;
case 0 !== preg_match('/^.*\.' . static::TYPE_LESS . '/', $path):
$this->type = static::TYPE_LESS;
break;
default:
$this->type = 'unknown';
$extension = strtolower(pathinfo($path, PATHINFO_EXTENSION));
if (in_array($extension, static::$extensions)) {
$this->type = $extension;
} else {
$this->type = static::TYPE_UNKNOWN;
}
}

Expand Down