@@ -35,15 +35,15 @@ public function __construct()
35
35
{
36
36
parent ::__construct ();
37
37
38
- $ this ['storage_driver ' ] = getenv ('STORAGE_DRIVER ' );
39
- $ this ['storage_path ' ] = getenv ('STORAGE_PATH ' );
40
- $ this ['cache_ttl ' ] = (int ) getenv ('CACHE_TTL ' );
41
- $ this ['allowed_domains ' ] = explode (', ' , ( string ) getenv ('ALLOWED_DOMAINS ' ));
42
- $ this ['image_compression ' ] = (int ) getenv ('IMAGE_COMPRESSION ' );
43
-
44
- $ this [LoggerInterface::class] = static fn () => new BrefLogger (
45
- ( string ) getenv ('LOG_LEVEL ' ),
46
- ( string ) getenv ('LOG_STREAM ' )
38
+ $ this ['storage_driver ' ] = $ this -> getEnv ('STORAGE_DRIVER ' );
39
+ $ this ['storage_path ' ] = $ this -> getEnv ('STORAGE_PATH ' );
40
+ $ this ['cache_ttl ' ] = (int ) $ this -> getEnv ('CACHE_TTL ' );
41
+ $ this ['allowed_domains ' ] = explode (', ' , $ this -> getEnv ('ALLOWED_DOMAINS ' ));
42
+ $ this ['image_compression ' ] = (int ) $ this -> getEnv ('IMAGE_COMPRESSION ' );
43
+
44
+ $ this [LoggerInterface::class] = fn () => new BrefLogger (
45
+ $ this -> getEnv ('LOG_LEVEL ' ),
46
+ $ this -> getEnv ('LOG_STREAM ' )
47
47
);
48
48
49
49
$ this [SymfonyFilesystem::class] = static fn () => new SymfonyFilesystem ();
@@ -52,20 +52,20 @@ public function __construct()
52
52
case 's3 ' :
53
53
$ awsClient = new S3Client (
54
54
[
55
- 'version ' => ' latest ' ,
56
- 'region ' => getenv ('S3_REGION ' ),
57
- 'endpoint ' => getenv ('S3_ENDPOINT ' ),
58
- 'use_path_style_endpoint ' => 1 === ((int ) getenv ('S3_PATH_STYLE_ENDPOINT ' )),
55
+ 'version ' => $ this -> getEnv ( ' S3_VERSION ' , ' latest ') ,
56
+ 'region ' => $ this -> getEnv ('S3_REGION ' ),
57
+ 'endpoint ' => $ this -> getEnv ('S3_ENDPOINT ' ),
58
+ 'use_path_style_endpoint ' => 1 === ((int ) $ this -> getEnv ('S3_PATH_STYLE_ENDPOINT ' , 1 )),
59
59
'credentials ' => [
60
- 'key ' => getenv ('S3_ACCESS_KEY ' ),
61
- 'secret ' => getenv ('S3_SECRET_KEY ' ),
60
+ 'key ' => $ this -> getEnv ('S3_ACCESS_KEY ' ),
61
+ 'secret ' => $ this -> getEnv ('S3_SECRET_KEY ' ),
62
62
],
63
63
]
64
64
);
65
65
66
66
$ this [FilesystemAdapter::class] = new AwsS3V3Adapter (
67
67
client: $ awsClient ,
68
- bucket: ( string ) getenv ('S3_BUCKET ' ),
68
+ bucket: $ this -> getEnv ('S3_BUCKET ' ),
69
69
visibility: new PortableVisibilityConverter (Visibility::PRIVATE ),
70
70
);
71
71
break ;
@@ -79,7 +79,7 @@ public function __construct()
79
79
}
80
80
81
81
$ this [UrlFilesystemAdapter::class] = static fn (self $ c ) => new UrlFilesystemAdapter (
82
- $ c [SymfonyFilesystem::class]
82
+ $ c [SymfonyFilesystem::class],
83
83
);
84
84
$ this [LeagueFilesystem::class] = static fn (self $ c ) => new LeagueFilesystem ($ c [FilesystemAdapter::class]);
85
85
$ this [Storage::class] = static fn (self $ c ) => new Storage (
@@ -105,4 +105,15 @@ public function __construct()
105
105
$ c [LoggerInterface::class],
106
106
);
107
107
}
108
+
109
+ private function getEnv (string $ key , mixed $ default = null ): string
110
+ {
111
+ // phpcs:ignore
112
+ if (false === \array_key_exists ($ key , $ _ENV )) {
113
+ return $ default ;
114
+ }
115
+
116
+ // phpcs:ignore
117
+ return (string ) $ _ENV [$ key ];
118
+ }
108
119
}
0 commit comments