Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
93.33% |
14 / 15 |
|
87.50% |
7 / 8 |
CRAP | |
0.00% |
0 / 1 |
| Infix | |
93.33% |
14 / 15 |
|
87.50% |
7 / 8 |
9.02 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
| getOp | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getArg1 | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getArg2 | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| inCurlies | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| render | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| toMMLTree | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| extractIdentifiers | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | declare( strict_types = 1 ); |
| 4 | |
| 5 | namespace MediaWiki\Extension\Math\WikiTexVC\Nodes; |
| 6 | |
| 7 | class Infix extends TexNode { |
| 8 | |
| 9 | /** @var string */ |
| 10 | private $op; |
| 11 | /** @var TexArray */ |
| 12 | private $arg1; |
| 13 | /** @var TexArray */ |
| 14 | private $arg2; |
| 15 | |
| 16 | public function __construct( string $op, TexArray $arg1, TexArray $arg2 ) { |
| 17 | parent::__construct( $op, $arg1, $arg2 ); |
| 18 | $this->op = $op; |
| 19 | $this->arg1 = $arg1; |
| 20 | $this->arg2 = $arg2; |
| 21 | } |
| 22 | |
| 23 | /** |
| 24 | * @return string |
| 25 | */ |
| 26 | public function getOp(): string { |
| 27 | return $this->op; |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * @return TexArray |
| 32 | */ |
| 33 | public function getArg1(): TexArray { |
| 34 | return $this->arg1; |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * @return TexArray |
| 39 | */ |
| 40 | public function getArg2(): TexArray { |
| 41 | return $this->arg2; |
| 42 | } |
| 43 | |
| 44 | /** @inheritDoc */ |
| 45 | public function inCurlies() { |
| 46 | return $this->render(); |
| 47 | } |
| 48 | |
| 49 | /** @inheritDoc */ |
| 50 | public function render() { |
| 51 | return '{' . $this->arg1->render() . |
| 52 | ' ' . $this->op . ' ' . |
| 53 | $this->arg2->render() . '}'; |
| 54 | } |
| 55 | |
| 56 | /** @inheritDoc */ |
| 57 | public function toMMLTree( array $arguments = [], array &$state = [] ) { |
| 58 | return $this->parseToMML( $this->op, $arguments, null ); |
| 59 | } |
| 60 | |
| 61 | /** @inheritDoc */ |
| 62 | public function extractIdentifiers( $args = null ) { |
| 63 | if ( $args == null ) { |
| 64 | $args = [ $this->arg1, $this->arg2 ]; |
| 65 | } |
| 66 | |
| 67 | return parent::extractIdentifiers( $args ); |
| 68 | } |
| 69 | |
| 70 | } |