src/Parsing/Css.php
protected function analyseStyle($code)
    {
        // clean the spaces
        $code = preg_replace('/[\s]+/', ' ', $code);

        // remove the comments
        $code = preg_replace('/\/\*.*?\*\//s', '', $code);

        // split each CSS code "selector { value }"
        preg_match_all('/([^{}]+){([^}]*)}/isU', $code, $match);

        // for each CSS code
        $amountMatch = count($match[0]);
        for ($k = 0; $k < $amountMatch; $k++) {

            // selectors
            $names = strtolower(trim($match[1][$k]));

            // css style
            $styles = trim($match[2][$k]);

            // explode each value
            $styles = explode(';', $styles);

            // parse each value
            $css = array();
            foreach ($styles as $style) {
                $tmp = explode(':', $style);
                if (count($tmp) > 1) {
                    $cod = $tmp[0];
                    unset($tmp[0]);
                    $tmp = implode(':', $tmp);
                    $css[trim(strtolower($cod))] = trim($tmp);
                }
            }

            // explode the names
            $names = explode(',', $names);

            // save the values for each names
            foreach ($names as $name) {
                // clean the name
                $name = trim($name);

                // if a selector with something like :hover => continue
                if (strpos($name, ':') !== false) {
                    continue;
                }

                // save the value
                if (!isset($this->css[$name])) {
                    $this->css[$name] = $css;
                } else {
                    $this->css[$name] = array_merge($this->css[$name], $css);
                }

            }
        }

        // get he list of the keys
        $this->cssKeys = array_flip(array_keys($this->css));
    }
protected function analyseStyle($code)
    {
        // clean the spaces
        $code = preg_replace('/[\s]+/', ' ', $code);

        // remove the comments
        $code = preg_replace('/\/\*.*?\*\//s', '', $code);

        // split each CSS code "selector { value }"
        preg_match_all('/([^{}]+){([^}]*)}/isU', $code, $match);

        // for each CSS code
        $amountMatch = count($match[0]);
        for ($k = 0; $k < $amountMatch; $k++) {

            // selectors
            $names = strtolower(trim($match[1][$k]));

            // css style
            $styles = trim($match[2][$k]);

            // explode each value
            $styles = explode(';', $styles);

            // parse each value
            $css = array();
            foreach ($styles as $style) {
                $tmp = explode(':', $style);
                if (count($tmp) > 1) {
                    $cod = $tmp[0];
                    unset($tmp[0]);
                    $tmp = implode(':', $tmp);
                    $css[trim(strtolower($cod))] = trim($tmp);
                }
            }

            // explode the names
            $names = explode(',', $names);

            // save the values for each names
            foreach ($names as $name) {
                // clean the name
                $name = trim($name);

                // if a selector with something like :hover => continue
                if (strpos($name, ':') !== false) {
                    continue;
                }

                // save the value
                if (!isset($this->css[$name])) {
                    $this->css[$name] = $css;
                } else {
                    $this->css[$name] = array_merge($this->css[$name], $css);
                }

            }
        }

        // get he list of the keys
        $this->cssKeys = array_flip(array_keys($this->css));
    }
protected function analyseStyle ( $ code ) { // clean the spaces $ code = preg_replace ( '/[\s]+/' , ' ' , $ code ) ; // remove the comments $ code = preg_replace ( '/\/\*.*?\*\//s' , '' , $ code ) ; // split each CSS code "selector { value }" preg_match_all ( '/([^{}]+){([^}]*)}/isU' , $ code , $ match ) ; // for each CSS code $ amountMatch = count ( $ match [ 0 ] ) ; for ( $ k = 0 ; $ k < $ amountMatch ; $ k ++ ) { // selectors $ names = strtolower ( trim ( $ match [ 1 ] [ $ k ] ) ) ; // css style $ styles = trim ( $ match [ 2 ] [ $ k ] ) ; // explode each value $ styles = explode ( ';' , $ styles ) ; // parse each value $ css = array ( ) ; foreach ( $ styles as $ style ) { $ tmp = explode ( ':' , $ style ) ; if ( count ( $ tmp ) > 1 ) { $ cod = $ tmp [ 0 ] ; unset ( $ tmp [ 0 ] ) ; $ tmp = implode ( ':' , $ tmp ) ; $ css [ trim ( strtolower ( $ cod ) ) ] = trim ( $ tmp ) ; } } // explode the names $ names = explode ( ',' , $ names ) ; // save the values for each names foreach ( $ names as $ name ) { // clean the name $ name = trim ( $ name ) ; // if a selector with something like :hover => continue if ( strpos ( $ name , ':' ) !== false ) { continue ; } // save the value if ( ! isset ( $ this -> css [ $ name ] ) ) { $ this -> css [ $ name ] = $ css ; } else { $ this -> css [ $ name ] = array_merge ( $ this -> css [ $ name ] , $ css ) ; } } } // get he list of the keys $ this -> cssKeys = array_flip ( array_keys ( $ this -> css ) ) ; }
Read a css content

@param  &string $code

@return void
Read a css content