Bubble CSS @imports to the top or prepend a warning if an import is detected not at the top.

@param string $css

@return string
503219
protected function handleCssImports($css)
    {
        if ($this->options['bubbleCssImports']) {
            // bubble CSS imports
            preg_match_all('/@import.*?;/', $css, $imports);
            $css = implode('', $imports[0]) . preg_replace('/@import.*?;/', '', $css);

            return $css;
        }

        if ('' === $this->options['importWarning']) {
            return $css;
        }

        // remove comments so we don't mistake { in a comment as a block
        $noCommentCss = preg_replace('@/\\*[\\s\\S]*?\\*/@', '', $css);
        $lastImportPos = strrpos($noCommentCss, '@import');
        $firstBlockPos = strpos($noCommentCss, '{');
        if (false !== $lastImportPos
            && false !== $firstBlockPos
            && $firstBlockPos < $lastImportPos
        ) {
            // { appears before @import : prepend warning
            $css = $this->options['importWarning'] . $css;
        }

        return $css;
    }
256388
public function setCss($css, array $options = array())
    {
        $options['asset'] = $css;
        $options['type'] = 'css';

        return $this->asset->set($options);
    }
1318411
public static function css_files(array $files) {
        if (empty($files)) {
            return '';
        }

        $compressed = array();
        foreach ($files as $file) {
            $content = file_get_contents($file);
            if ($content === false) {
                $compressed[] = "\n\n/* Cannot read CSS file ".basename(dirname(dirname($file))).'/'.basename(dirname($file)).'/'.basename($file)."*/\n\n";
                continue;
            }
            $compressed[] = self::css($content);
        }

        return implode("\n", $compressed);
    }
774148
public function css($attributes = null)
	{
		if( ! $this->css)
			return '';

		$assets = ($this->pipeline) ? array($this->cssPipeline()) : $this->css;

		if($attributes instanceof Closure)
			return $attributes->__invoke($assets);

		// Build attributes
		$attributes = (array) $attributes;
		unset($attributes['href']);

		if( ! array_key_exists('type', $attributes))
			$attributes['type'] = 'text/css';

		if( ! array_key_exists('rel', $attributes))
			$attributes['rel'] = 'stylesheet';

		$attributes = $this->buildTagAttributes($attributes);

		// Build tags
		$output = '';
		foreach($assets as $asset)
			$output .= '<link href="' . $asset . '"' . $attributes . " />\n";

		return $output;
	}
1037371
public function css($css) {
        $css = trim($css);
        if (substr($css, -1) !== ';') {
            $css = $css . ';';
        }
        return $this->att(['style' => $css]);
    }
1010100
public function readBorder($css)
    {
        // border none
        $none = array('type' => 'none', 'width' => 0, 'color' => array(0, 0, 0));

        // default value
        $type  = 'solid';
        $width = $this->convertToMM('1pt');
        $color = array(0, 0, 0);

        // clean up the values
        $css = explode(' ', $css);
        foreach ($css as $k => $v) {
            $v = trim($v);
            if ($v) $css[$k] = $v;
            else    unset($css[$k]);
        }
        $css = array_values($css);

        // read the values
        $res = null;
        foreach ($css as $value) {

            // if no border => return none
            if ($value=='none' || $value=='hidden') {
                return $none;
            }

            // try to convert the value as a distance
            $tmp = $this->convertToMM($value);

            // if the convert is ok => it is a width
            if ($tmp!==null) {
                $width = $tmp;
            // else, it could be the type
            } else if (in_array($value, array('solid', 'dotted', 'dashed', 'double'))) {
                $type = $value;
            // else, it could be the color
            } else {
                $tmp = $this->convertToColor($value, $res);
                if ($res) $color = $tmp;
            }
        }

        // if no witdh => return none
        if (!$width) return $none;

        // return the border properties
        return array('type' => $type, 'width' => $width, 'color' => $color);
    }
325241
public function addCss($css)
    {
        $this->addHook(function($document) use ($css) {
            $document->addCss('/'.$css);
        });

        return $this;
    }
762820
public static function compress($css)
    {
        $css = (string) $css;
        try {
            $css_minifier = new static($css);
            $minified_css = $css_minifier->min();
            return $minified_css;
        } catch (\Exception $exception) {
            return $css;
        }
    }
29655
protected function parseCssClasses($classes)
    {
        if (is_string($classes)) {
            $classes = explode(' ', $classes);
        }

        if (!is_array($classes)) {
            throw new InvalidArgumentException('CSS Class(es) must be a space-delimited string or an array');
        }

        return array_filter($classes, 'strlen');
    }
549643
protected function style($css, array $attr = null)
    {
        $attr = $this->fixInternalAttr($attr);
        $attr = $this->escaper->attr($attr);
        return "<style $attr>$css</style>";
    }
1140491
public function getCssCode()
    {
        $html = '';
        foreach ($this->css as $css) {
            $html .= sprintf('<link rel="stylesheet" href="%s"/>', $css);
        }
        return $html;
    }
718440
protected function _minify($css)
    {
        return ($this->_minifier instanceof \Tollwerk\Squeezr\Css\Minifier) ? $this->_minifier->minify($css) : $css;
    }
979787
public function &inline($styles)
    {
        $css_object = new CssObject();

        $css_object->setType('inline');
        $css_object->setCss($styles);

        $this->add($css_object);

        return $css_object;
    }
811339
public function css( $cssClasses )
    {
        if ( ! $cssClasses )
        {
            return $this;
        }

        $cssClasses = explode( ' ', $cssClasses );

        foreach ( $cssClasses as $cssClass )
        {
            if ( $cssClass && false === in_array( $cssClass, $this->cssClasses ) )
            {
                $this->cssClasses[] = $cssClass;
            }
        }

        return $this;
    }
243692
public static function prepend($css, $path)
	{
		self::$_prependPath = $path;

		$css = self::_trimUrls($css);

		// append
		$css = preg_replace_callback('/@import\\s+([\'"])(.*?)[\'"]/'
			,array(self::$className, '_processUriCB'), $css);
		$css = preg_replace_callback('/url\\(\\s*([^\\)\\s]+)\\s*\\)/'
			,array(self::$className, '_processUriCB'), $css);

		self::$_prependPath = null;
		return $css;
	}
490523
private static function fixLeftAndRight($css) {
		$css = preg_replace(self::$patterns['left'], self::$patterns['tmpToken'], $css);
		$css = preg_replace(self::$patterns['right'], 'left', $css);
		$css = str_replace(self::$patterns['tmpToken'], 'right', $css);

		return $css;
	}
914138
protected function removeCss($css)
    {
        $key=array_keys($this->data['css']['internal'],$css);
        if($key){
            array_splice($this->data['css']['internal'],$key[0],1);
        }

        $key=array_keys($this->data['css']['external'],$css);
        if($key){
            array_splice($this->data['css']['external'],$key[0],1);
        }
    }