Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
46.67% covered (danger)
46.67%
7 / 15
83.33% covered (warning)
83.33%
5 / 6
CRAP
0.00% covered (danger)
0.00%
0 / 1
ChemWord
46.67% covered (danger)
46.67%
7 / 15
83.33% covered (warning)
83.33%
5 / 6
14.43
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 getLeft
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getRight
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 render
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 renderMML
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
6
 extractIdentifiers
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare( strict_types = 1 );
4
5namespace MediaWiki\Extension\Math\WikiTexVC\Nodes;
6
7use MediaWiki\Extension\Math\WikiTexVC\MMLnodes\MMLmrow;
8use MediaWiki\Extension\Math\WikiTexVC\MMLnodes\MMLmtext;
9
10class ChemWord extends TexNode {
11
12    /** @var TexNode */
13    public $left;
14    /** @var TexNode */
15    public $right;
16
17    public function __construct( TexNode $left, TexNode $right ) {
18        parent::__construct( $left, $right );
19        $this->left = $left;
20        $this->right = $right;
21    }
22
23    /**
24     * @return TexNode
25     */
26    public function getLeft(): TexNode {
27        return $this->left;
28    }
29
30    /**
31     * @return TexNode
32     */
33    public function getRight(): TexNode {
34        return $this->right;
35    }
36
37    public function render() {
38        return $this->left->render() . $this->right->render();
39    }
40
41    public function renderMML( $arguments = [], $state = [] ) {
42        $mmlMrow = new MMLmrow();
43        $mtextLeft = new MMLmtext( "", [ "mathcolor" => "red" ] );
44        $mtextRight = new MMLmtext();
45        // If right has empty literal content is resolved as dash
46        $right = $this->getRight()->getArgs()[0] == "" ? "-" : $this->getRight()->renderMML( [],
47            $state );
48        return $mmlMrow->encapsulateRaw( $mmlMrow->encapsulateRaw(
49            $mtextLeft->encapsulateRaw( $this->getLeft()->renderMML( [], $state ) )
50            . $mtextRight->encapsulateRaw( $right ) ) );
51    }
52
53    public function extractIdentifiers( $args = null ) {
54        return [];
55    }
56
57}