示例#1
0
 /**
  * Convert a rule-string into an object
  *
  * @param string $rule
  * @param int    $originalOrder
  * @return array
  */
 public function convertToObjects($rule, $originalOrder)
 {
     $rule = $this->cleanup($rule);
     $chunks = explode('{', $rule);
     if (!isset($chunks[1])) {
         return array();
     }
     $propertiesProcessor = new PropertyProcessor();
     $rules = array();
     $selectors = (array) explode(',', trim($chunks[0]));
     $properties = $propertiesProcessor->splitIntoSeparateProperties($chunks[1]);
     foreach ($selectors as $selector) {
         $selector = trim($selector);
         $specificity = $this->calculateSpecificityBasedOnASelector($selector);
         $rules[] = new Rule($selector, $propertiesProcessor->convertArrayToObjects($properties, $specificity), $specificity, $originalOrder);
     }
     return $rules;
 }
 /**
  * Get the current inline styles for a given DOMElement
  *
  * @param \DOMElement $element
  * @return Css\Property\Property[]
  */
 public function getInlineStyles(\DOMElement $element)
 {
     $processor = new PropertyProcessor();
     return $processor->convertArrayToObjects($processor->splitIntoSeparateProperties($element->getAttribute('style')));
 }