Skip to content
This repository was archived by the owner on Mar 14, 2024. It is now read-only.

Commit e587507

Browse files
authored
Merge pull request #4 from paneidos/use-default
Pass $default to underlying function
2 parents 4365f2a + fb418b9 commit e587507

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/helpers.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ function credentials(string $key, $default = null) {
1010
$credentials = app(Credentials::class);
1111
$credentials->load($filename);
1212

13-
return $credentials->get($key);
13+
return $credentials->get($key, $default);
1414
} catch (ReflectionException $e) {
1515
return Credentials::CONFIG_PREFIX.$key;
1616
}
1717
}
18-
}
18+
}

tests/CredentialTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,22 @@ public function it_can_use_the_helper_function()
124124
$this->assertSame('my-secret-value', credentials('key'));
125125
}
126126

127+
/** @test */
128+
public function it_can_give_a_default_to_the_helper_function()
129+
{
130+
$this->app['config']->set('credentials.file', __DIR__ . '/temp/credentials.php.enc');
131+
132+
$data = [
133+
'key' => 'my-secret-value'
134+
];
135+
136+
$credentials = app(Credentials::class);
137+
138+
$credentials->store($data, __DIR__ . '/temp/credentials.php.enc');
139+
140+
$this->assertSame('my-fallback-value', credentials('wrong-key', 'my-fallback-value'));
141+
}
142+
127143
/** @test */
128144
public function it_replaces_credential_strings_in_the_configuration_files()
129145
{

0 commit comments

Comments
 (0)