Sabberworm\CSS\Parser::__construct PHP Метод

__construct() публичный Метод

public __construct ( $sText, Sabberworm\CSS\Settings $oParserSettings = null )
$oParserSettings Sabberworm\CSS\Settings
    public function __construct($sText, Settings $oParserSettings = null)
    {
        $this->iCurrentPosition = 0;
        if ($oParserSettings === null) {
            $oParserSettings = Settings::create();
        }
        $this->oParserSettings = $oParserSettings;
        if ($this->oParserSettings->bMultibyteSupport) {
            $this->aText = preg_split('//u', $sText, null, PREG_SPLIT_NO_EMPTY);
        } else {
            if ($sText === '') {
                $this->aText = array();
            } else {
                $this->aText = str_split($sText);
            }
        }
        $this->blockRules = explode('/', AtRule::BLOCK_RULES);
        foreach (explode('/', Size::ABSOLUTE_SIZE_UNITS . '/' . Size::RELATIVE_SIZE_UNITS . '/' . Size::NON_SIZE_UNITS) as $val) {
            $iSize = strlen($val);
            if (!isset($this->aSizeUnits[$iSize])) {
                $this->aSizeUnits[$iSize] = array();
            }
            $this->aSizeUnits[$iSize][strtolower($val)] = $val;
        }
        ksort($this->aSizeUnits, SORT_NUMERIC);
    }

Usage Example

Пример #1
0
 /**
  * Constructor.
  *
  * @param string $css The CSS content.
  */
 public function __construct($css)
 {
     $settings = \Sabberworm\CSS\Settings::create();
     $settings->withLenientParsing();
     parent::__construct($css, $settings);
 }