-
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.
Conductor describes dependency checks, this implementation should be consistent with that naming.
- Loading branch information
Showing
13 changed files
with
229 additions
and
356 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shrink\Conductor\Laravel; | ||
|
||
use Shrink\Conductor\ChecksDependencyStatus; | ||
|
||
interface CollectsApplicationDependencyChecks | ||
{ | ||
/** | ||
* @return array<string,\Shrink\Conductor\ChecksDependencyStatus> | ||
*/ | ||
public function listDependencyChecks(): array; | ||
|
||
/** | ||
* @throws \InvalidArgumentException | ||
*/ | ||
public function dependencyCheckById(string $id): ChecksDependencyStatus; | ||
|
||
public function isDependencyCheckRegistered(string $id): bool; | ||
|
||
/** | ||
* @throws \InvalidArgumentException | ||
*/ | ||
public function addDependencyCheck( | ||
string $id, | ||
ChecksDependencyStatus $check | ||
): 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
This file was deleted.
Oops, something went wrong.
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,62 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shrink\Conductor\Laravel; | ||
|
||
use InvalidArgumentException; | ||
use Shrink\Conductor\ChecksDependencyStatus; | ||
use function array_key_exists; | ||
use function preg_match; | ||
|
||
final class DependencyChecksArray implements CollectsApplicationDependencyChecks | ||
{ | ||
/** | ||
* @var array<string,\Shrink\Conductor\ChecksDependencyStatus> | ||
*/ | ||
private array $checks = []; | ||
|
||
/** | ||
* @return array<string,\Shrink\Conductor\ChecksDependencyStatus> | ||
*/ | ||
public function listDependencyChecks(): array | ||
{ | ||
return $this->checks; | ||
} | ||
|
||
/** | ||
* @throws \InvalidArgumentException | ||
*/ | ||
public function dependencyCheckById(string $id): ChecksDependencyStatus | ||
{ | ||
if (! $this->isDependencyCheckRegistered($id)) { | ||
throw new InvalidArgumentException(<<<EXCEPTION | ||
Dependency check not found for ID {$id} | ||
EXCEPTION); | ||
} | ||
|
||
return $this->checks[$id]; | ||
} | ||
|
||
public function isDependencyCheckRegistered(string $id): bool | ||
{ | ||
return array_key_exists($id, $this->checks); | ||
} | ||
|
||
/** | ||
* @throws \InvalidArgumentException | ||
*/ | ||
public function addDependencyCheck( | ||
string $id, | ||
ChecksDependencyStatus $check | ||
): void { | ||
if (preg_match('%^[\w-]{1,32}$%', $id) !== 1) { | ||
throw new InvalidArgumentException(<<<EXCEPTION | ||
Dependency ID must be 1 to 32 word characters (ASCII letter, digit, | ||
underscore or hyphen) in length | ||
EXCEPTION); | ||
} | ||
|
||
$this->checks[$id] = $check; | ||
} | ||
} |
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.