Skip to content

Commit

Permalink
changes after code review
Browse files Browse the repository at this point in the history
  • Loading branch information
simbera committed Mar 4, 2024
1 parent b74e858 commit c34418d
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Supportive/OutputFormatter/MermaidJSOutputFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ final class MermaidJSOutputFormatter implements OutputFormatterInterface
{
/** @var array{direction: string, groups: array<string, string[]>} */
private array $config;
private const GRAPH_TYPE = 'flowchart %s;';

private const GRAPH_END = ' end;';
private const SUBGRAPH = ' subgraph %sGroup;';
private const LAYER = ' %s;';
private const GRAPH_NODE_FORMAT = ' %s -->|%d| %s;';
private const VIOLATION_STYLE_FORMAT = ' linkStyle %d stroke:red,stroke-width:4px;';

Expand All @@ -42,16 +46,16 @@ public function finish(
$violations = $result->violations();
$buffer = '';

$buffer .= sprintf('flowchart %s;'.PHP_EOL, $this->config['direction']);
$buffer .= sprintf(self::GRAPH_TYPE.PHP_EOL, $this->config['direction']);

foreach ($this->config['groups'] as $subGraphName => $layers) {
$buffer .= sprintf(' subgraph %sGroup;'.PHP_EOL, $subGraphName);
$buffer .= sprintf(self::SUBGRAPH.PHP_EOL, $subGraphName);

foreach ($layers as $layer) {
$buffer .= sprintf(' %s;'.PHP_EOL, $layer);
$buffer .= sprintf(self::LAYER.PHP_EOL, $layer);
}

$buffer .= ' end;'.PHP_EOL;
$buffer .= self::GRAPH_END.PHP_EOL;
}

$linkCount = 0;
Expand Down

0 comments on commit c34418d

Please sign in to comment.