Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
7 / 7 |
|
100.00% |
7 / 7 |
CRAP | |
100.00% |
1 / 1 |
Stylesheet | |
100.00% |
7 / 7 |
|
100.00% |
7 / 7 |
8 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |||
__clone | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getRuleList | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getPosition | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
toTokenArray | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
toComponentValueArray | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
__toString | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | /** |
3 | * @file |
4 | * @license https://opensource.org/licenses/Apache-2.0 Apache-2.0 |
5 | */ |
6 | |
7 | namespace Wikimedia\CSS\Objects; |
8 | |
9 | use Wikimedia\CSS\Util; |
10 | |
11 | /** |
12 | * Represent a stylesheet |
13 | * @note This isn't necessarily a "CSS stylesheet" though. |
14 | * @warning If you're not using the provided Sanitizer classes to further sanitize |
15 | * the CSS, you'll want to manually filter out any at-rules named "charset" |
16 | * before stringifying and/or prepend `@charset "utf-8";` after stringifying |
17 | * this object. |
18 | */ |
19 | class Stylesheet implements CSSObject { |
20 | |
21 | /** @var RuleList */ |
22 | protected $ruleList; |
23 | |
24 | /** |
25 | * @param RuleList|null $rules |
26 | */ |
27 | public function __construct( RuleList $rules = null ) { |
28 | $this->ruleList = $rules ?: new RuleList(); |
29 | } |
30 | |
31 | public function __clone() { |
32 | $this->ruleList = clone $this->ruleList; |
33 | } |
34 | |
35 | /** |
36 | * @return RuleList |
37 | */ |
38 | public function getRuleList() { |
39 | return $this->ruleList; |
40 | } |
41 | |
42 | /** @inheritDoc */ |
43 | public function getPosition() { |
44 | // Stylesheets don't really have a position |
45 | return [ 0, 0 ]; |
46 | } |
47 | |
48 | /** @inheritDoc */ |
49 | public function toTokenArray() { |
50 | return $this->ruleList->toTokenArray(); |
51 | } |
52 | |
53 | /** @inheritDoc */ |
54 | public function toComponentValueArray() { |
55 | return $this->ruleList->toComponentValueArray(); |
56 | } |
57 | |
58 | public function __toString() { |
59 | return Util::stringify( $this ); |
60 | } |
61 | } |