File tree Expand file tree Collapse file tree 3 files changed +24
-0
lines changed
main/php/com/amazon/aws/lambda
test/php/com/amazon/aws/lambda/unittest Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ AWS Lambda change log
55
66## 1.1.0 / 2021-08-28
77
8+ * Added accessor for environment varibales, ` Environment::variable() `
9+ (@thekid )
810* Added accessor for temporary directory, ` Environment::tempDir() `
911 (@thekid )
1012* Added accessor for environment root path, ` Environment::taskroot() `
Original file line number Diff line number Diff line change @@ -35,6 +35,16 @@ public function tempDir(): Path {
3535 return new Path (sys_get_temp_dir ());
3636 }
3737
38+ /**
39+ * Returns a given environment variable
40+ *
41+ * @param string $name
42+ * @return ?string
43+ */
44+ public function variable ($ name ) {
45+ return $ _ENV [$ name ] ?? null ;
46+ }
47+
3848 /**
3949 * Writes a trace message
4050 *
Original file line number Diff line number Diff line change @@ -30,6 +30,18 @@ public function tempDir() {
3030 Assert::instance (Path::class, (new Environment ('. ' ))->tempDir ());
3131 }
3232
33+ #[Test]
34+ public function variable () {
35+ $ _ENV ['TEST ' ]= 'true ' ;
36+ Assert::equals ('true ' , (new Environment ('. ' ))->variable ('TEST ' ));
37+ }
38+
39+ #[Test]
40+ public function non_existant_variable () {
41+ unset($ _ENV ['TEST ' ]);
42+ Assert::null ((new Environment ('. ' ))->variable ('TEST ' ));
43+ }
44+
3345 #[Test]
3446 public function trace () {
3547 $ stream = new MemoryOutputStream ();
You can’t perform that action at this time.
0 commit comments