Skip to content

Commit

Permalink
Switching default value / return from config to allow config to be go…
Browse files Browse the repository at this point in the history
…tten before default values.
  • Loading branch information
Bradley Cornford committed Sep 28, 2017
1 parent 4f79a68 commit 059baf9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions spec/Cornford/Setter/SettingSpec.php
Expand Up @@ -220,6 +220,7 @@ function it_can_get_a_setting_with_a_default_value()
$query->shouldReceive('lists')->andReturn(false);

$repository = Mockery::mock('Illuminate\Config\Repository');
$repository->shouldReceive('has')->andReturn(false);

$cache = Mockery::mock('Illuminate\Cache\Repository');

Expand All @@ -239,6 +240,7 @@ function it_can_get_a_setting_with_a_default_value_of_false()
$query->shouldReceive('lists')->andReturn(false);

$repository = Mockery::mock('Illuminate\Config\Repository');
$repository->shouldReceive('has')->andReturn(false);

$cache = Mockery::mock('Illuminate\Cache\Repository');

Expand All @@ -258,6 +260,7 @@ function it_can_get_a_setting_with_a_default_value_of_an_empty_array()
$query->shouldReceive('lists')->andReturn(false);

$repository = Mockery::mock('Illuminate\Config\Repository');
$repository->shouldReceive('has')->andReturn(false);

$cache = Mockery::mock('Illuminate\Cache\Repository');

Expand Down
8 changes: 4 additions & 4 deletions src/Cornford/Setter/Setting.php
Expand Up @@ -61,15 +61,15 @@ public function get($key, $default = null)
if ($results) {
return $this->returnResults($results, $key);
}

if ($this->configHas($key)) {
return $this->returnConfig($key);
}

if ($default !== null) {
return $default;
}

if ($this->configHas($key)) {
return $this->returnConfig($key);
}

return false;
}

Expand Down

0 comments on commit 059baf9

Please sign in to comment.