-
-
Notifications
You must be signed in to change notification settings - Fork 38
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
23 changed files
with
935 additions
and
35 deletions.
There are no files selected for viewing
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,14 @@ | ||
<?php | ||
|
||
namespace YlsIdeas\FeatureFlags\Contracts; | ||
|
||
use YlsIdeas\FeatureFlags\Support\ActionDebugLog; | ||
|
||
interface DebuggableFlag extends ActionableFlag | ||
{ | ||
public function isDebuggable(): bool; | ||
|
||
public function storeInspectionInformation(string $pipe, string $reason, ?bool $result = null); | ||
|
||
public function log(): ?ActionDebugLog; | ||
} |
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,8 @@ | ||
<?php | ||
|
||
namespace YlsIdeas\FeatureFlags\Contracts; | ||
|
||
interface ExpiredFeaturesHandler | ||
{ | ||
public function isExpired(string $feature): void; | ||
} |
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,8 @@ | ||
<?php | ||
|
||
namespace YlsIdeas\FeatureFlags\Contracts; | ||
|
||
interface Features | ||
{ | ||
public function accessible(string $feature): bool; | ||
} |
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,20 @@ | ||
<?php | ||
|
||
namespace YlsIdeas\FeatureFlags\Exceptions; | ||
|
||
class FeatureExpired extends \RuntimeException | ||
{ | ||
public function __construct( | ||
protected string $feature, | ||
string $message = "", | ||
int $code = 0, | ||
?\Throwable $previous = null | ||
) { | ||
parent::__construct($message, $code, $previous); | ||
} | ||
|
||
protected function feature(): string | ||
{ | ||
return $this->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,28 @@ | ||
<?php | ||
|
||
namespace YlsIdeas\FeatureFlags; | ||
|
||
use YlsIdeas\FeatureFlags\Contracts\ExpiredFeaturesHandler as ExpiredFeaturesHandlerContract; | ||
|
||
/** | ||
* @see \YlsIdeas\FeatureFlags\Tests\ExpiredFeaturesHandlerTest | ||
*/ | ||
class ExpiredFeaturesHandler implements ExpiredFeaturesHandlerContract | ||
{ | ||
/** | ||
* @var callable | ||
*/ | ||
protected mixed $handler; | ||
|
||
public function __construct(protected array $features, callable $handler) | ||
{ | ||
$this->handler = $handler; | ||
} | ||
|
||
public function isExpired(string $feature): void | ||
{ | ||
if (in_array($feature, $this->features)) { | ||
call_user_func($this->handler, $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
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
Oops, something went wrong.