Skip to content

Commit 2a5eb1a

Browse files
author
Viacheslav Danilin
committed
refactor: rename env var to PSALM_LARAVEL_PLUGIN_CACHE_PATH for better clarity
1 parent acf10cb commit 2a5eb1a

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/Providers/CacheDirectoryProvider.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,17 @@
77
use function getenv;
88
use function rtrim;
99

10+
use const DIRECTORY_SEPARATOR;
11+
1012
final class CacheDirectoryProvider
1113
{
1214
public static function getCacheLocation(): string
1315
{
14-
$env = getenv('LARAVEL_PLUGIN_CACHE_PATH');
16+
$env = getenv('PSALM_LARAVEL_PLUGIN_CACHE_PATH');
1517
if ($env !== false && $env !== '') {
16-
return rtrim($env, '/');
18+
return rtrim($env, DIRECTORY_SEPARATOR);
1719
}
1820

19-
return __DIR__ . '/../../cache';
21+
return __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'cache';
2022
}
2123
}

tests/Unit/Providers/CacheDirectoryProviderTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,27 @@
1010
use function putenv;
1111
use function sys_get_temp_dir;
1212

13+
use const DIRECTORY_SEPARATOR;
14+
1315
final class CacheDirectoryProviderTest extends TestCase
1416
{
1517
protected function tearDown(): void
1618
{
17-
putenv('LARAVEL_PLUGIN_CACHE_PATH');
19+
putenv('PSALM_LARAVEL_PLUGIN_CACHE_PATH');
1820
}
1921

2022
public function testReturnsDefaultPathIfEnvNotSet(): void
2123
{
2224
$path = CacheDirectoryProvider::getCacheLocation();
2325

24-
$this->assertStringEndsWith('/cache', $path);
26+
$this->assertStringEndsWith(DIRECTORY_SEPARATOR . 'cache', $path);
2527
$this->assertFileExists($path);
2628
}
2729

2830
public function testReturnsCustomPathFromEnv(): void
2931
{
3032
$custom = sys_get_temp_dir() . '/psalm-laravel-stubs-test';
31-
putenv("LARAVEL_PLUGIN_CACHE_PATH={$custom}");
33+
putenv("PSALM_LARAVEL_PLUGIN_CACHE_PATH={$custom}");
3234

3335
$this->assertSame($custom, CacheDirectoryProvider::getCacheLocation());
3436
}

0 commit comments

Comments
 (0)