-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
201 additions
and
86 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,13 @@ | ||
<?php | ||
|
||
return [ | ||
'default' => env('FOGGLE_STORE', 'array'), | ||
|
||
'stores' => [ | ||
|
||
'array' => [ | ||
'driver' => 'array', | ||
], | ||
|
||
], | ||
]; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace YouCanShop\Foggle\Drivers; | ||
|
||
use Illuminate\Contracts\Events\Dispatcher; | ||
use YouCanShop\Foggle\Contracts\Driver; | ||
|
||
class ArrayDriver implements Driver | ||
{ | ||
/** @var Dispatcher */ | ||
protected Dispatcher $dispatcher; | ||
|
||
/** @var array<string, (callable(mixed $context): mixed)> */ | ||
protected array $resolvers; | ||
|
||
/** | ||
* @param Dispatcher $dispatcher | ||
* @param array<string, (callable(mixed $context): mixed)> $resolvers | ||
*/ | ||
public function __construct(Dispatcher $dispatcher, array $resolvers) | ||
{ | ||
$this->dispatcher = $dispatcher; | ||
$this->resolvers = $resolvers; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function defined(): array | ||
{ | ||
return array_keys($this->resolvers); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function get(string $name, $context) | ||
{ | ||
return $this->resolvers[$name]($context); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function define(string $name, callable $resolver): void | ||
{ | ||
$this->resolvers[$name] = $resolver; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace YouCanShop\Foggle; | ||
|
||
class Lazily | ||
{ | ||
public string $feature; | ||
|
||
public function __construct(string $feature) | ||
{ | ||
$this->feature = $feature; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
providers: | ||
- YouCanShop\Foggle\FoggleServiceProvider | ||
|
||
workbench: | ||
install: true |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
use function Orchestra\Testbench\workbench_path; | ||
|
||
it('discovers features', function () { | ||
$foggle = $this->foggle(); | ||
|
||
$foggle->discover( | ||
'Workbench\\App\\Features', | ||
workbench_path('app/Features') | ||
); | ||
|
||
expect($foggle->defined())->toBeGreaterThan(0); | ||
}); | ||
|
||
it('retrieves a feature\'s value by name', function () { | ||
$foggle = $this->foggle(); | ||
|
||
$foggle->discover( | ||
'Workbench\\App\\Features', | ||
workbench_path('app/Features') | ||
); | ||
|
||
expect($foggle->get('always-true', null))->toBeTrue(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters