<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

/**
 * Description of cssmin
 *
 * @author Igor Ratsun
 */
class cssmin {

    protected $_input = '';

    public function __construct($input = '') {
        $this->_input = $input;
    }

    public function min() {
        // Remove comments
        $this->_input = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $this->_input);
        // Remove whitespace
        $this->_input = str_replace(array("\r\n", "\r", "\n", "\t"), '', $this->_input);
        // Remove spaces
        $this->_input = preg_replace('(\s+)', ' ', $this->_input);
        // Remove other
        $this->_input = str_replace(array(' {', '{ ', ' }', '} ', '; ', ' ;', ': ', ' :', ' >', '> ', ' <', '< '), array('{', '{', '}', '}', ';', ';', ':', ':', '>', '>', '<', '<'), $this->_input);

        return $this->_input;
    }

}
