Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
6 / 6 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| ComponentValueList | |
100.00% |
6 / 6 |
|
100.00% |
2 / 2 |
8 | |
100.00% |
1 / 1 |
| testObjects | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
7 | |||
| toComponentValueArray | |
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 InvalidArgumentException; |
| 10 | |
| 11 | /** |
| 12 | * Represent a list of CSS component values, eg. `10px 20px` is the |
| 13 | * component value list in the declaration `margin: 10px 20px;`. |
| 14 | */ |
| 15 | class ComponentValueList extends CSSObjectList { |
| 16 | /** |
| 17 | * @var string |
| 18 | */ |
| 19 | protected static $objectType = ComponentValue::class; |
| 20 | |
| 21 | /** @inheritDoc */ |
| 22 | protected static function testObjects( array $objects ) { |
| 23 | foreach ( $objects as $object ) { |
| 24 | $type = $object instanceof Token ? $object->type() : 'n/a'; |
| 25 | switch ( $type ) { |
| 26 | case Token::T_FUNCTION: |
| 27 | case Token::T_LEFT_BRACKET: |
| 28 | case Token::T_LEFT_PAREN: |
| 29 | case Token::T_LEFT_BRACE: |
| 30 | throw new InvalidArgumentException( |
| 31 | static::class . " may not contain tokens of type \"$type\"." |
| 32 | ); |
| 33 | } |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | /** @inheritDoc */ |
| 38 | public function toComponentValueArray() { |
| 39 | // Much simpler |
| 40 | return $this->objects; |
| 41 | } |
| 42 | } |