Skip to content

Commit 899db2a

Browse files
committed
Add Environment::local()
1 parent c809cac commit 899db2a

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/main/php/com/amazon/aws/lambda/Environment.class.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ public function tempDir(): Path {
3838
return new Path(sys_get_temp_dir());
3939
}
4040

41+
/** Returns whether this is a local invocation */
42+
public function local(): bool {
43+
return isset($this->variables['AWS_LOCAL']);
44+
}
45+
4146
/**
4247
* Returns a given environment variable
4348
*

src/test/php/com/amazon/aws/lambda/unittest/EnvironmentTest.class.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ public function non_existant_variable() {
4646
Assert::null((new Environment('.', null, []))->variable('TEST'));
4747
}
4848

49+
#[Test]
50+
public function not_local_by_default() {
51+
Assert::false((new Environment('.', null, []))->local());
52+
}
53+
54+
#[Test]
55+
public function local() {
56+
Assert::true((new Environment('.', null, ['AWS_LOCAL' => true]))->local());
57+
}
58+
4959
#[Test]
5060
public function credentials() {
5161
$env= [

0 commit comments

Comments
 (0)