| 1 |
<?php |
| 2 |
|
| 3 |
declare( strict_types = 1 ); |
| 4 |
|
| 5 |
namespace MediaWiki\Extension\Math\WikiTexVC\Nodes; |
| 6 |
|
| 7 |
class Infix extends TexNode { |
| 8 |
|
| 9 |
|
| 10 |
private $op; |
| 11 |
|
| 12 |
private $arg1; |
| 13 |
|
| 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 |
|
| 25 |
|
| 26 |
public function getOp(): string { |
| 27 |
return $this->op; |
| 28 |
} |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
public function getArg1(): TexArray { |
| 34 |
return $this->arg1; |
| 35 |
} |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
public function getArg2(): TexArray { |
| 41 |
return $this->arg2; |
| 42 |
} |
| 43 |
|
| 44 |
|
| 45 |
public function inCurlies() { |
| 46 |
return $this->render(); |
| 47 |
} |
| 48 |
|
| 49 |
|
| 50 |
public function render() { |
| 51 |
return '{' . $this->arg1->render() . |
| 52 |
' ' . $this->op . ' ' . |
| 53 |
$this->arg2->render() . '}'; |
| 54 |
} |
| 55 |
|
| 56 |
|
| 57 |
public function renderMML( $arguments = [], &$state = [] ) { |
| 58 |
return $this->parseToMML( $this->op, $arguments, null ); |
| 59 |
} |
| 60 |
|
| 61 |
|
| 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 |
} |