| Server IP : 138.197.107.151 / Your IP : 216.73.217.7 Web Server : Apache/2.4.58 (Ubuntu) System : Linux BloxBy-Builder 6.8.0-71-generic #71-Ubuntu SMP PREEMPT_DYNAMIC Tue Jul 22 16:52:38 UTC 2025 x86_64 User : wpbetasites_mrakzqskir ( 1022) PHP Version : 8.3.6 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/silversharkadmindev/vendor/sabberworm/php-css-parser/src/ |
Upload File : |
<?php
declare(strict_types=1);
namespace Sabberworm\CSS;
/**
* Parser settings class.
*
* Configure parser behaviour here.
*/
class Settings
{
/**
* Multi-byte string support.
*
* If `true` (`mbstring` extension must be enabled), will use (slower) `mb_strlen`, `mb_convert_case`, `mb_substr`
* and `mb_strpos` functions. Otherwise, the normal (ASCII-Only) functions will be used.
*
* @var bool
*/
private $multibyteSupport;
/**
* The default charset for the CSS if no `@charset` declaration is found. Defaults to utf-8.
*
* @var non-empty-string
*/
private $defaultCharset = 'utf-8';
/**
* Whether the parser silently ignore invalid rules instead of choking on them.
*
* @var bool
*/
private $lenientParsing = true;
private function __construct()
{
$this->multibyteSupport = \extension_loaded('mbstring');
}
public static function create(): self
{
return new Settings();
}
/**
* Enables/disables multi-byte string support.
*
* If `true` (`mbstring` extension must be enabled), will use (slower) `mb_strlen`, `mb_convert_case`, `mb_substr`
* and `mb_strpos` functions. Otherwise, the normal (ASCII-Only) functions will be used.
*
* @return $this fluent interface
*/
public function withMultibyteSupport(bool $multibyteSupport = true): self
{
$this->multibyteSupport = $multibyteSupport;
return $this;
}
/**
* Sets the charset to be used if the CSS does not contain an `@charset` declaration.
*
* @param non-empty-string $defaultCharset
*
* @return $this fluent interface
*/
public function withDefaultCharset(string $defaultCharset): self
{
$this->defaultCharset = $defaultCharset;
return $this;
}
/**
* Configures whether the parser should silently ignore invalid rules.
*
* @return $this fluent interface
*/
public function withLenientParsing(bool $usesLenientParsing = true): self
{
$this->lenientParsing = $usesLenientParsing;
return $this;
}
/**
* Configures the parser to choke on invalid rules.
*
* @return $this fluent interface
*/
public function beStrict(): self
{
return $this->withLenientParsing(false);
}
/**
* @internal
*/
public function hasMultibyteSupport(): bool
{
return $this->multibyteSupport;
}
/**
* @return non-empty-string
*
* @internal
*/
public function getDefaultCharset(): string
{
return $this->defaultCharset;
}
/**
* @internal
*/
public function usesLenientParsing(): bool
{
return $this->lenientParsing;
}
}