Exemplo n.º 1
0
 /**
  * @param string|null $ruleString
  * @param StyleSheet $styleSheet
  */
 public function __construct($ruleString = null, StyleSheet $styleSheet = null)
 {
     if ($styleSheet !== null) {
         $this->setStyleSheet($styleSheet);
     }
     if ($ruleString !== null) {
         $ruleString = Placeholder::replaceStringsAndComments($ruleString);
         $this->parseRuleString($ruleString);
     }
 }
Exemplo n.º 2
0
 /**
  * @param string $keyframeList
  * @param StyleSheet $styleSheet
  */
 public function __construct($keyframeList = "", StyleSheet $styleSheet = null)
 {
     if ($styleSheet !== null) {
         $this->setStyleSheet($styleSheet);
     }
     if ($keyframeList !== "") {
         $keyframeList = Placeholder::replaceStringsAndComments($keyframeList);
         $this->parseKeyframeList($keyframeList);
     }
 }
Exemplo n.º 3
0
 /**
  * Checks the selector value.
  *
  * @param $value
  * @return bool
  */
 public function checkValue(&$value)
 {
     if (is_string($value)) {
         $value = Placeholder::replaceStringsAndComments($value);
         $value = Placeholder::removeCommentPlaceholders($value, true);
         $value = preg_replace('/[ ]+/', ' ', $value);
         $value = Placeholder::replaceStringPlaceholders($value, true);
         return true;
     } else {
         throw new \InvalidArgumentException("Invalid type '" . gettype($value) . "' for argument 'value' given.");
     }
 }
Exemplo n.º 4
0
 /**
  * Gets a prepared version of the CSS content for parsing.
  *
  * @return string
  */
 protected function getPreparedCssContent()
 {
     if ($this->preparedContent === null) {
         $this->preparedContent = Placeholder::replaceStringsAndComments($this->getCssContent());
         // Move comments from the end of the line to the beginning to make it easier to
         // detect, to which rule they belong to
         $this->preparedContent = preg_replace('/^([^\\r\\n]+)(_COMMENT_[a-f0-9]{32}_)([\\r\\n\\t\\f]+)/m', "\\2\n\\1\\3", $this->preparedContent);
         // Remove white space characters before comments
         $this->preparedContent = preg_replace('/^([ \\t\\f]*)(_COMMENT_[a-f0-9]{32}_)/m', "\\2\n", $this->preparedContent);
         // Very important: Split long lines, because parsing long lines (char by char) costs a lot performance
         // (several thousand percent...).
         $this->preparedContent = str_replace(["{", "}", ";"], ["{\n", "}\n", ";\n"], $this->preparedContent);
     }
     return $this->preparedContent;
 }
Exemplo n.º 5
0
 /**
  * Checks the declaration value.
  *
  * @param string $value
  * @return bool
  */
 public function checkValue(&$value)
 {
     if (is_string($value)) {
         $value = Placeholder::replaceStringsAndComments($value);
         $value = Placeholder::removeCommentPlaceholders($value, true);
         $value = Placeholder::replaceStringPlaceholders($value, true);
         $value = trim($value);
         if ($value !== '') {
             return true;
         } else {
             $this->setIsValid(false);
         }
     } else {
         throw new \InvalidArgumentException("Invalid type '" . gettype($value) . "' for argument 'value' given.");
     }
 }