| Total Complexity | 6 |
| Total Lines | 42 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | class NodeLabelBuilder |
||
| 18 | { |
||
| 19 | /** @var TemplateEngine */ |
||
| 20 | private $engine; |
||
| 21 | |||
| 22 | /** @var HtmlLabelStyle */ |
||
| 23 | private $style; |
||
| 24 | |||
| 25 | 18 | public function __construct(TemplateEngine $engine, HtmlLabelStyle $style) |
|
| 29 | 18 | } |
|
| 30 | |||
| 31 | 12 | public function labelForClass(ClassDefinition $class): string |
|
| 36 | ]); |
||
| 37 | } |
||
| 38 | |||
| 39 | 6 | public function labelForInterface(InterfaceDefinition $interface): string |
|
| 44 | ]); |
||
| 45 | } |
||
| 46 | |||
| 47 | 18 | private function buildLabel(string $template, array $options): string |
|
| 48 | { |
||
| 49 | try { |
||
| 50 | 18 | return "<{$this->removeNewLinesFrom($this->engine->render($template, $options))}>"; |
|
| 51 | 3 | } catch (LoaderError | RuntimeError | SyntaxError $e) { |
|
| 52 | 3 | throw new NodeLabelError($e); |
|
| 53 | } |
||
| 54 | } |
||
| 55 | |||
| 56 | 15 | private function removeNewLinesFrom(string $label): string |
|
| 59 | } |
||
| 60 | } |
||
| 61 |