-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautoload.php
More file actions
109 lines (98 loc) · 2.68 KB
/
Copy pathautoload.php
File metadata and controls
109 lines (98 loc) · 2.68 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
/**
* Mantle Framework Application Helpers
*
* Intentionally not Namespaced to allow for root-level access to
* framework methods.
*
* @phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound, Squiz.Commenting.FunctionComment
*
* @package Mantle
*/
declare(strict_types=1);
use Mantle\Application\Application;
use Mantle\Support\Environment;
use Mantle\Support\Mixed_Data;
use function Mantle\Support\Helpers\mixed;
if ( ! function_exists( 'app' ) ) {
/**
* Get the available container instance.
*
* @param string|null $abstract Abstract to resolve.
* @param array<mixed> $parameters Parameters.
* @return mixed|Application
* @phpstan-return ($abstract is null ? Application : mixed)
*/
function app( ?string $abstract = null, array $parameters = [] ) {
if ( is_null( $abstract ) ) {
return Application::get_instance();
}
return Application::get_instance()->make( $abstract, $parameters );
}
}
if ( ! function_exists( 'environment' ) ) {
/**
* Gets the value of an environment variable.
*
* @see Mantle\Support\Environment
*
* @param string $key Environment variable key.
* @param mixed $default Default value.
*/
function environment( string $key, $default = null ): mixed {
return Environment::get( $key, $default );
}
}
if ( ! function_exists( 'environment_mixed' ) ) {
/**
* Gets the value of an environment variable as a Mixed Data object.
*
* @param string $key Environment variable key.
* @param mixed $default Default value.
*/
function environment_mixed( string $key, $default = null ): Mixed_Data {
return mixed( environment( $key, $default ) );
}
}
if ( ! function_exists( 'base_path' ) ) {
/**
* Get the base path to the application.
*
* @param string $path Path to append.
*/
function base_path( string $path = '' ): string {
return app()->get_base_path( $path );
}
}
if ( ! function_exists( 'app_path' ) ) {
/**
* Get the application path (the app/ folder).
*
* @param string $path Path to append.
*/
function app_path( string $path = '' ): string {
return app()->get_app_path( $path );
}
}
if ( ! function_exists( 'storage_path' ) ) {
/**
* Get the path to the storage folder.
*
* @param string $path Path to append.
*/
function storage_path( string $path = '' ): string {
return app()->get_storage_path( $path );
}
}
if ( ! function_exists( 'now' ) ) {
/**
* Create a new Carbon instance for the current time.
*
* Non-namespaced alias for Mantle\Support\Helpers\now().
*
* @param DateTimeZone|string|null $tz Timezone.
*/
function now( \DateTimeZone|string|null $tz = null ): \Mantle\Support\Carbon {
return \Mantle\Support\Helpers\now( $tz );
}
}