| Conditions | 7 |
| Paths | 5 |
| Total Lines | 30 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 16 |
| CRAP Score | 7.0099 |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | 3 | public function visit(DOMAttr $att, Compiler $context) |
|
| 19 | { |
||
| 20 | 3 | $node = $att->ownerElement; |
|
| 21 | |||
| 22 | 3 | $expessions = ParserHelper::staticSplitExpression($att->value, ","); |
|
| 23 | |||
| 24 | 3 | if (! isset($expessions[0]) || ! strlen($expessions[0])) { |
|
| 25 | throw new \Exception("The count for trans-n is required"); |
||
| 26 | } |
||
| 27 | |||
| 28 | 3 | $with = '{\'%count%\':' . $expessions[0] . '}'; |
|
| 29 | |||
| 30 | 3 | if (isset($expessions[1]) && strlen($expessions[1])) { |
|
| 31 | 2 | $with = "$with|merge(" . $expessions[1] . ')'; |
|
| 32 | } |
||
| 33 | |||
| 34 | 3 | $from = ''; |
|
| 35 | 3 | if (isset($expessions[2]) && strlen($expessions[2])) { |
|
| 36 | 1 | $from = " from $expessions[2]"; |
|
| 37 | } |
||
| 38 | |||
| 39 | 3 | $start = $context->createControlNode("transchoice " . $expessions[0] . " with $with".$from); |
|
| 40 | 3 | $end = $context->createControlNode("endtranschoice"); |
|
| 41 | |||
| 42 | 3 | $node->insertBefore($start, $node->firstChild); |
|
| 43 | |||
| 44 | 3 | $node->appendChild($end); |
|
| 45 | |||
| 46 | 3 | $node->removeAttributeNode($att); |
|
| 47 | 3 | } |
|
| 48 | } |
||
| 49 |