Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 16 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
MermaidTreeFormatter | |
0.00% |
0 / 16 |
|
0.00% |
0 / 4 |
42 | |
0.00% |
0 / 1 |
outputPerson | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
outputJunction | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
outputEdge | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getOutput | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
12 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Extension\Genealogy; |
4 | |
5 | class MermaidTreeFormatter extends TreeFormatter { |
6 | |
7 | /** |
8 | * @inheritDoc |
9 | */ |
10 | protected function outputPerson( Person $person ) { |
11 | $id = $this->varId( $person->getTitle()->getPrefixedText() ); |
12 | $this->out( 'person', $id, $id . '("' . $person->getTitleHtml() . '")' ); |
13 | $this->out( 'person', $id . '_c', "click $id \"" . $person->getTitle()->getInternalURL() . '"' ); |
14 | } |
15 | |
16 | /** |
17 | * @inheritDoc |
18 | */ |
19 | protected function outputJunction( $peopleId ) { |
20 | $this->out( 'partner', $peopleId, $this->varId( $peopleId ) . '{" "}' ); |
21 | } |
22 | |
23 | /** |
24 | * @inheritDoc |
25 | */ |
26 | protected function outputEdge( $group, $key, $from, $to, $towardsJunction = false ) { |
27 | $line = $this->varId( $from ) . ' --> ' . $this->varId( $to ); |
28 | $this->out( $group, $key, $line ); |
29 | } |
30 | |
31 | /** |
32 | * @inheritDoc |
33 | */ |
34 | public function getOutput() { |
35 | $out = "graph LR;\n\n" |
36 | . "%% People\n" |
37 | . implode( ";\n", $this->out['person'] ) . ";\n\n"; |
38 | if ( isset( $this->out['partner'] ) ) { |
39 | $out .= "%% Partners\n" |
40 | . implode( ";\n", $this->out['partner'] ) . ";\n\n"; |
41 | } |
42 | if ( isset( $this->out['child'] ) ) { |
43 | $out .= "%% Children\n" |
44 | . implode( ";\n", $this->out['child'] ) . ";\n\n"; |
45 | } |
46 | return $out; |
47 | } |
48 | } |