Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
ComponentValueList
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
2 / 2
8
100.00% covered (success)
100.00%
1 / 1
 testObjects
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
7
 toComponentValueArray
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2/**
3 * @file
4 * @license https://opensource.org/licenses/Apache-2.0 Apache-2.0
5 */
6
7namespace Wikimedia\CSS\Objects;
8
9use InvalidArgumentException;
10
11/**
12 * Represent a list of CSS declarations
13 */
14class ComponentValueList extends CSSObjectList {
15    /**
16     * @var string
17     */
18    protected static $objectType = ComponentValue::class;
19
20    /** @inheritDoc */
21    protected static function testObjects( array $objects ) {
22        foreach ( $objects as $object ) {
23            $type = $object instanceof Token ? $object->type() : 'n/a';
24            switch ( $type ) {
25                case Token::T_FUNCTION:
26                case Token::T_LEFT_BRACKET:
27                case Token::T_LEFT_PAREN:
28                case Token::T_LEFT_BRACE:
29                    throw new InvalidArgumentException(
30                        static::class . " may not contain tokens of type \"$type\"."
31                    );
32            }
33        }
34    }
35
36    /** @inheritDoc */
37    public function toComponentValueArray() {
38        // Much simpler
39        return $this->objects;
40    }
41}