Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 11 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
LuaLibrary | |
0.00% |
0 / 11 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
register | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
expr | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Extension\ParserFunctions; |
4 | |
5 | use MediaWiki\Extension\Scribunto\Engines\LuaCommon\LibraryBase; |
6 | use MediaWiki\Extension\Scribunto\Engines\LuaCommon\LuaError; |
7 | |
8 | class LuaLibrary extends LibraryBase { |
9 | public function register() { |
10 | $lib = [ |
11 | 'expr' => [ $this, 'expr' ], |
12 | ]; |
13 | |
14 | return $this->getEngine()->registerInterface( |
15 | __DIR__ . '/mw.ext.ParserFunctions.lua', $lib, [] |
16 | ); |
17 | } |
18 | |
19 | public function expr( $expression = null ) { |
20 | $this->checkType( 'mw.ext.ParserFunctions.expr', 1, $expression, 'string' ); |
21 | try { |
22 | $exprParser = new ExprParser(); |
23 | return [ $exprParser->doExpression( $expression ) ]; |
24 | } catch ( ExprError $e ) { |
25 | throw new LuaError( $e->getMessage() ); |
26 | } |
27 | } |
28 | |
29 | } |