mirror of
https://github.com/smogon/pokemon-showdown-client.git
synced 2026-03-22 01:55:56 -05:00
60 lines
1.3 KiB
PHP
60 lines
1.3 KiB
PHP
<?php
|
|
/**
|
|
* @file
|
|
* @license https://opensource.org/licenses/Apache-2.0 Apache-2.0
|
|
*/
|
|
|
|
namespace Wikimedia\CSS\Objects;
|
|
|
|
use Wikimedia\CSS\Util;
|
|
use Wikimedia\CSS\Sanitizer\Sanitizer;
|
|
|
|
/**
|
|
* Represent a stylesheet
|
|
* @note This isn't necessarily a "CSS stylesheet" though.
|
|
* @warning If you're not using the provided Sanitizer classes to further sanitize
|
|
* the CSS, you'll want to manually filter out any at-rules named "charset"
|
|
* before stringifying and/or prepend `@charset "utf-8";` after stringifying
|
|
* this object.
|
|
*/
|
|
class Stylesheet implements CSSObject {
|
|
|
|
/** @var RuleList */
|
|
protected $ruleList;
|
|
|
|
/**
|
|
* @param RuleList $rules
|
|
*/
|
|
public function __construct( RuleList $rules = null ) {
|
|
$this->ruleList = $rules ?: new RuleList();
|
|
}
|
|
|
|
public function __clone() {
|
|
$this->ruleList = clone( $this->ruleList );
|
|
}
|
|
|
|
/**
|
|
* @return RuleList
|
|
*/
|
|
public function getRuleList() {
|
|
return $this->ruleList;
|
|
}
|
|
|
|
public function getPosition() {
|
|
// Stylesheets don't really have a position
|
|
return [ 0, 0 ];
|
|
}
|
|
|
|
public function toTokenArray() {
|
|
return $this->ruleList->toTokenArray();
|
|
}
|
|
|
|
public function toComponentValueArray() {
|
|
return $this->ruleList->toComponentValueArray();
|
|
}
|
|
|
|
public function __toString() {
|
|
return Util::stringify( $this );
|
|
}
|
|
}
|