/** * @access public * @param $source * @return string */ public function pre_process($source) { // Go through each custom function foreach ($this->properties as $name => $property) { $obj = $property[0]; $method = $property[1]; // Find them in the CSS foreach (Scaffold_Helper_CSS::find_properties($name, $source->contents) as $found) { // Call the hook method for this function $result = call_user_func_array(array($obj, $method), array($found['value'])); // Replace it in the CSS $source->contents = str_replace($found['property'], $result, $source->contents); } } }
public function testFind_property() { $string = ' id{background:blue} #id2{color:blue} #id3{background-color:red} #id4{dbackground:blue} #id5{color:red;background:blue} '; $expected = array(0 => array('string' => 'id{background:blue}', 'selector' => 'id', 'property' => 'background:blue', 'value' => 'blue'), 1 => array('string' => '#id5{color:red;background:blue}', 'selector' => '#id5', 'property' => 'background:blue', 'value' => 'blue')); $output = Scaffold_Helper_CSS::find_properties('background', $string); $this->assertEquals($expected, $output); }