public function parse($source, $isFile = true)
{
# Richard Lyon - 2011-10-25 - ignore unfound files
# Richard Lyon - 2011-10-25 - add multiple files to load functions
if (!$source) {
return $this->toTree($source);
}
if (is_array($source)) {
$return = null;
foreach ($source as $key => $value) {
if (is_numeric($key)) {
$code = $value;
$type = true;
} else {
$code = $key;
$type = $value;
}
if ($return === null) {
$return = $this->parse($code, $type);
} else {
/** @var SassNode $return */
$newNode = $this->parse($code, $type);
foreach ($newNode->children as $children) {
array_push($return->children, $children);
}
}
}
return $return;
}
if ($isFile && ($files = SassFile::get_file($source, $this))) {
$files_source = '';
foreach ($files as $file) {
$this->filename = $file;
$this->syntax = substr(strrchr($file, '.'), 1);
if ($this->syntax == SassFile::CSS) {
$this->property_syntax = "css";
} elseif (!$this->property_syntax && $this->syntax == SassFile::SCSS) {
$this->property_syntax = "scss";
}
if ($this->syntax !== SassFile::SASS && $this->syntax !== SassFile::SCSS && $this->syntax !== SassFile::CSS) {
if ($this->debug) {
throw new SassException('Invalid {what}', array('{what}' => 'syntax option'));
}
return FALSE;
}
$files_source .= SassFile::get_file_contents($this->filename);
}
return $this->toTree($files_source);
} else {
return $this->toTree($source);
}
}