Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
NonEmpty
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
2 / 2
4
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 generateMatches
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
3
1<?php
2declare( strict_types = 1 );
3
4/**
5 * @file
6 * @license https://opensource.org/licenses/Apache-2.0 Apache-2.0
7 */
8
9namespace Wikimedia\CSS\Grammar;
10
11use Wikimedia\CSS\Objects\ComponentValueList;
12
13/**
14 * Matcher that requires its sub-Matcher has only non-empty matches ("!" multiplier)
15 * @see https://www.w3.org/TR/2024/WD-css-values-4-20240312/#mult-req
16 */
17class NonEmpty extends Matcher {
18    /** @var Matcher */
19    protected $matcher;
20
21    /**
22     * @param Matcher $matcher
23     */
24    public function __construct( Matcher $matcher ) {
25        $this->matcher = $matcher;
26    }
27
28    /** @inheritDoc */
29    protected function generateMatches( ComponentValueList $values, $start, array $options ) {
30        foreach ( $this->matcher->generateMatches( $values, $start, $options ) as $match ) {
31            if ( $match->getLength() !== 0 ) {
32                yield $this->makeMatch( $values, $start, $match->getNext(), $match );
33            }
34        }
35    }
36}