Skip to content

Commit

Permalink
Introduces an Conditionable interface
Browse files Browse the repository at this point in the history
  • Loading branch information
andizer committed Apr 21, 2023
1 parent 9157cc5 commit 70d4cba
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
10 changes: 10 additions & 0 deletions src/Conditionals/Conditionable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
declare(strict_types=1);

namespace Favit\Bootstrap\Conditionals;

interface Conditionable {

public function get_conditionals(): array;

}
7 changes: 3 additions & 4 deletions src/Conditionals/Conditionals.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Favit\Bootstrap\Conditionals;

use Favit\Bootstrap\Integrations\Integration;
use League\Container\Container;

final class Conditionals {
Expand All @@ -21,12 +20,12 @@ public function __construct( Container $container ) {
/**
* Checks the conditionals.
*
* @param Integration $integration The integration to check.
* @param Conditionable $conditionable The conditionable to check.
*
* @return bool
*/
public function check( Integration $integration ): bool {
foreach ( $integration->get_conditionals() as $conditional ) {
public function check( Conditionable $conditionable ): bool {
foreach ( $conditionable->get_conditionals() as $conditional ) {
$instance = $this->get_conditional( $conditional );
if ( ! $instance->is_met() ) {
return false;
Expand Down
7 changes: 4 additions & 3 deletions src/Integrations/Integration.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?php
declare(strict_types=1);

namespace Favit\Bootstrap\Integrations;

interface Integration {
use Favit\Bootstrap\Conditionals\Conditionable;

public function register(): void;
interface Integration extends Conditionable {

public function get_conditionals(): array;
public function register(): void;

}

0 comments on commit 70d4cba

Please sign in to comment.