Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
7 / 7
CRAP
100.00% covered (success)
100.00%
9 / 9
Wikimedia\CSS\Objects\Stylesheet
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
7 / 7
8
100.00% covered (success)
100.00%
9 / 9
 __construct
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
2 / 2
 __clone
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 getRuleList
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 getPosition
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 toTokenArray
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 toComponentValueArray
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 __toString
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
<?php
/**
 * @file
 * @license https://opensource.org/licenses/Apache-2.0 Apache-2.0
 */
namespace Wikimedia\CSS\Objects;
use Wikimedia\CSS\Util;
/**
 * 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|null $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;
    }
    /** @inheritDoc */
    public function getPosition() {
        // Stylesheets don't really have a position
        return [ 0, 0 ];
    }
    /** @inheritDoc */
    public function toTokenArray() {
        return $this->ruleList->toTokenArray();
    }
    /** @inheritDoc */
    public function toComponentValueArray() {
        return $this->ruleList->toComponentValueArray();
    }
    public function __toString() {
        return Util::stringify( $this );
    }
}