Skip to content

Commit 55812b0

Browse files
committed
Added CodeTransformerKernel
1 parent 2f780bb commit 55812b0

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

src/CodeTransformerKernel.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
namespace Okapi\CodeTransformer;
4+
5+
use Okapi\Singleton\Singleton;
6+
7+
/**
8+
* # Code Transformer Kernel
9+
*
10+
* The `CodeTransformerKernel` is the heart of the Code Transformer library.
11+
* It manages an environment for Code Transformation.
12+
*
13+
* 1. Extends this class and define a list of transformers in the
14+
* `$transformers` property.
15+
* 2. Call the `init()` method early in the application lifecycle.
16+
*/
17+
abstract class CodeTransformerKernel
18+
{
19+
use Singleton;
20+
21+
/**
22+
* List of transformers to be applied.
23+
*
24+
* @var class-string<Transformer>[]
25+
*/
26+
protected array $transformers = [];
27+
28+
/**
29+
* Initialize the kernel.
30+
*
31+
* @param string|null $cacheDir The cache directory.
32+
* <br><b>Default:</b> ROOT_DIR/cache/code-transformer<br>
33+
* @param int|null $cacheFileMode The cache file mode.
34+
* <br><b>Default:</b> 0777 & ~{@link umask()}<br>
35+
* @param bool|null $debug Enable debug mode. This will disable the cache.
36+
* <br><b>Default:</b> false<br>
37+
*
38+
* @return void
39+
*/
40+
public static function init(
41+
?string $cacheDir,
42+
?int $cacheFileMode = null,
43+
bool $debug = false,
44+
): void {}
45+
}

0 commit comments

Comments
 (0)