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    /** @inheritDoc */
38    public function render() {
39        return $this->left->render() . $this->right->render();
40    }
41
42    /** @inheritDoc */
43    public function renderMML( $arguments = [], &$state = [] ) {
44        $mmlMrow = new MMLmrow();
45        $mtextLeft = new MMLmtext( "", [ "mathcolor" => "red" ] );
46        $mtextRight = new MMLmtext();
47        // If right has empty literal content is resolved as dash
48        $right = $this->getRight()->getArgs()[0] == "" ? "-" : $this->getRight()->renderMML( [],
49            $state );
50        return $mmlMrow->encapsulateRaw( $mmlMrow->encapsulateRaw(
51            $mtextLeft->encapsulateRaw( $this->getLeft()->renderMML( [], $state ) )
52            . $mtextRight->encapsulateRaw( $right ) ) );
53    }
54
55    /** @inheritDoc */
56    public function extractIdentifiers( $args = null ) {
57        return [];
58    }
59
60}