Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
4 / 4 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| NonEmpty | |
100.00% |
4 / 4 |
|
100.00% |
2 / 2 |
4 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| generateMatches | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
3 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * @file |
| 4 | * @license https://opensource.org/licenses/Apache-2.0 Apache-2.0 |
| 5 | */ |
| 6 | |
| 7 | namespace Wikimedia\CSS\Grammar; |
| 8 | |
| 9 | use 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/2024/WD-css-values-4-20240312/#mult-req |
| 14 | */ |
| 15 | class 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 | } |