1010 use Tempest \Core \Kernel ;
1111 use function Tempest \Support \str ;
1212
13+ /**
14+ * Creates and sanitizes a file system path from the given `$parts`. The resulting path is not checked against the file system.
15+ */
1316 function path (string ...$ parts ): string
1417 {
1518 $ path = implode ('/ ' , $ parts );
@@ -21,18 +24,27 @@ function path(string ...$parts): string
2124 );
2225 }
2326
27+ /**
28+ * Creates a path scoped within the root of the project
29+ */
2430 function root_path (string ...$ parts ): string
2531 {
2632 return path (realpath (get (Kernel::class)->root ), ...$ parts );
2733 }
2834
35+ /**
36+ * Creates a path scoped within the src folder of the project
37+ */
2938 function src_path (string ...$ parts ): string
3039 {
3140 $ composer = get (Composer::class);
3241
3342 return path ($ composer ->mainNamespace ->path , ...$ parts );
3443 }
3544
45+ /**
46+ * Creates a namespace scoped within the main namespace of the project
47+ */
3648 function src_namespace (?string $ append = null ): string
3749 {
3850 $ composer = get (Composer::class);
@@ -44,6 +56,9 @@ function src_namespace(?string $append = null): string
4456 ->toString ();
4557 }
4658
59+ /**
60+ * Retrieves the given `$key` from the environment variables. If `$key` is not defined, `$default` is returned instead.
61+ */
4762 function env (string $ key , mixed $ default = null ): mixed
4863 {
4964 $ value = getenv ($ key );
@@ -60,6 +75,9 @@ function env(string $key, mixed $default = null): mixed
6075 };
6176 }
6277
78+ /**
79+ * Defer a task, will be run after a request has been sent or a command has executed
80+ */
6381 function defer (Closure $ closure ): void
6482 {
6583 get (DeferredTasks::class)->add ($ closure );
0 commit comments