Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
18 / 18 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
ParserUtil | |
100.00% |
18 / 18 |
|
100.00% |
2 / 2 |
4 | |
100.00% |
1 / 1 |
lst2arr | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
3 | |||
createOptions | |
100.00% |
11 / 11 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | declare( strict_types = 1 ); |
4 | |
5 | namespace MediaWiki\Extension\Math\WikiTexVC; |
6 | |
7 | use MediaWiki\Extension\Math\WikiTexVC\Nodes\TexArray; |
8 | |
9 | class ParserUtil { |
10 | |
11 | /** |
12 | * @param TexArray|null $l |
13 | * @return TexArray |
14 | */ |
15 | public static function lst2arr( $l ) { |
16 | $arr = new TexArray(); |
17 | |
18 | while ( $l !== null ) { |
19 | $first = $l->first(); |
20 | if ( $first !== null ) { |
21 | $arr->push( $l->first() ); |
22 | } |
23 | $l = $l->second(); |
24 | } |
25 | |
26 | return $arr; |
27 | } |
28 | |
29 | /** |
30 | * @param array|null $options |
31 | * @return array |
32 | */ |
33 | public static function createOptions( $options ) { |
34 | # get reference of the options for usage in functions and initialize with default values. |
35 | $optionsBase = [ |
36 | 'usemathrm' => false, |
37 | 'usemhchem' => false, |
38 | 'usemhchemtexified' => false, |
39 | 'useintent' => false, |
40 | 'oldtexvc' => false, |
41 | 'oldmhchem' => false, |
42 | 'debug' => false, |
43 | 'report_required' => false |
44 | ]; |
45 | return array_merge( $optionsBase, $options ?? [] ); |
46 | } |
47 | } |