Skip to content
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