Skip to content

Commit 73b3b4e

Browse files
committed
[TASK] Extract temp subdirectory path to constant
Extracts the temp subdirectory path to a public constant so tests can reference it directly, ensuring they stay in sync with the implementation.
1 parent b63339a commit 73b3b4e

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/Graphs/Renderer/PlantumlRenderer.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828

2929
final class PlantumlRenderer implements DiagramRenderer
3030
{
31+
public const TEMP_SUBDIRECTORY = '/phpdocumentor';
32+
3133
public function __construct(private readonly LoggerInterface $logger, private readonly string $plantUmlBinaryPath)
3234
{
3335
}
@@ -47,7 +49,7 @@ public function render(RenderContext $renderContext, string $diagram): string|nu
4749
@enduml
4850
PUML;
4951

50-
$tempDir = sys_get_temp_dir() . '/phpdocumentor';
52+
$tempDir = sys_get_temp_dir() . self::TEMP_SUBDIRECTORY;
5153
if (!is_dir($tempDir)) {
5254
mkdir($tempDir, 0o777, true);
5355
}

tests/unit/Renderer/PlantumlRendererTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ final class PlantumlRendererTest extends TestCase
2828
*/
2929
public function testRenderCreatesTempDirectoryWhenMissing(): void
3030
{
31-
$tempDir = sys_get_temp_dir() . '/phpdocumentor';
31+
$tempDir = sys_get_temp_dir() . PlantumlRenderer::TEMP_SUBDIRECTORY;
3232

3333
// Remove the directory if it exists to test creation
3434
if (is_dir($tempDir)) {

0 commit comments

Comments
 (0)