-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathUtil.php
58 lines (46 loc) · 1.44 KB
/
Util.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
namespace Okapi\CodeTransformer\Tests;
use Okapi\Filesystem\Filesystem;
class Util
{
private const TESTS_DIR = __DIR__;
public const CACHE_DIR = self::TESTS_DIR . '/cache';
private const CACHE_DIR_TRANSFORMED_TESTS = self::CACHE_DIR . '/transformed/tests';
public const CACHE_STATES_FILE = self::CACHE_DIR . '/cache_states.php';
public static function clearCache(): void
{
Filesystem::rm(
path: Util::CACHE_DIR,
recursive: true,
force: true,
);
}
public static function getFilePath(string $class): string
{
$class = str_replace(
search: 'Okapi\CodeTransformer\Tests\\',
replace: '',
subject: $class,
);
$class = str_replace(
search: '\\',
replace: '/',
subject: $class,
);
return Util::TESTS_DIR . '/' . $class . '.php';
}
public static function getTransformedFilePath(string $class): string
{
$class = str_replace(
search: 'Okapi\CodeTransformer\Tests\\',
replace: '',
subject: $class,
);
$class = str_replace(
search: '\\',
replace: '/',
subject: $class,
);
return Util::CACHE_DIR_TRANSFORMED_TESTS . '/' . $class . '.php';
}
}