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
2/**
3 * @file
4 * @license https://opensource.org/licenses/Apache-2.0 Apache-2.0
5 */
6
7namespace Wikimedia\CSS\Grammar;
8
9use Wikimedia\CSS\Objects\ComponentValueList;
10
11/**
12 * Matcher that requires its sub-Matcher has only non-empty matches ("!" multiplier)
13 * @see https://www.w3.org/TR/2019/CR-css-values-3-20190606/#mult-req
14 */
15class NonEmpty extends Matcher {
16    /** @var Matcher */
17    protected $matcher;
18
19    /**
20     * @param Matcher $matcher
21     */
22    public function __construct( Matcher $matcher ) {
23        $this->matcher = $matcher;
24    }
25
26    /** @inheritDoc */
27    protected function generateMatches( ComponentValueList $values, $start, array $options ) {
28        foreach ( $this->matcher->generateMatches( $values, $start, $options ) as $match ) {
29            if ( $match->getLength() !== 0 ) {
30                yield $this->makeMatch( $values, $start, $match->getNext(), $match );
31            }
32        }
33    }
34}