private function parseAtRule()
{
$this->consume('@');
$sIdentifier = $this->parseIdentifier();
$this->consumeWhiteSpace();
if ($sIdentifier === 'import') {
$oLocation = $this->parseURLValue();
$this->consumeWhiteSpace();
$sMediaQuery = null;
if (!$this->comes(';')) {
$sMediaQuery = $this->consumeUntil(';');
}
$this->consume(';');
return new Import($oLocation, $sMediaQuery);
} else {
if ($sIdentifier === 'charset') {
$sCharset = $this->parseStringValue();
$this->consumeWhiteSpace();
$this->consume(';');
$this->setCharset($sCharset->getString());
return new Charset($sCharset);
} else {
if ($this->identifierIs($sIdentifier, 'keyframes')) {
$oResult = new KeyFrame();
$oResult->setVendorKeyFrame($sIdentifier);
$oResult->setAnimationName(trim($this->consumeUntil('{', false, true)));
$this->consumeWhiteSpace();
$this->parseList($oResult);
return $oResult;
} else {
if ($sIdentifier === 'namespace') {
$sPrefix = null;
$mUrl = $this->parsePrimitiveValue();
if (!$this->comes(';')) {
$sPrefix = $mUrl;
$mUrl = $this->parsePrimitiveValue();
}
$this->consume(';');
if ($sPrefix !== null && !is_string($sPrefix)) {
throw new \Exception('Wrong namespace prefix ' . $sPrefix);
}
if (!($mUrl instanceof CSSString || $mUrl instanceof URL)) {
throw new \Exception('Wrong namespace url of invalid type ' . $mUrl);
}
return new CSSNamespace($mUrl, $sPrefix);
} else {
//Unknown other at rule (font-face or such)
$sArgs = trim($this->consumeUntil('{', false, true));
$this->consumeWhiteSpace();
$bUseRuleSet = true;
foreach ($this->blockRules as $sBlockRuleName) {
if ($this->identifierIs($sIdentifier, $sBlockRuleName)) {
$bUseRuleSet = false;
break;
}
}
if ($bUseRuleSet) {
$oAtRule = new AtRuleSet($sIdentifier, $sArgs);
$this->parseRuleSet($oAtRule);
} else {
$oAtRule = new AtRuleBlockList($sIdentifier, $sArgs);
$this->parseList($oAtRule);
}
return $oAtRule;
}
}
}
}
}