-
-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the
Features
syntax for accessing configuration
- Loading branch information
1 parent
e53d4b3
commit 326c5df
Showing
5 changed files
with
103 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Contains the Feature interface. | ||
* | ||
* @copyright Copyright (c) 2023 Vanilo UG | ||
* @author Attila Fulop | ||
* @license MIT | ||
* @since 2023-09-07 | ||
* | ||
*/ | ||
|
||
namespace Vanilo\Foundation\Contracts; | ||
|
||
interface Feature | ||
{ | ||
public function isEnabled(): bool; | ||
|
||
public function isDisabled(): bool; | ||
|
||
public function configuration(): array; | ||
} |
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,37 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Contains the Features class. | ||
* | ||
* @copyright Copyright (c) 2023 Vanilo UG | ||
* @author Attila Fulop | ||
* @license MIT | ||
* @since 2023-09-07 | ||
* | ||
*/ | ||
|
||
namespace Vanilo\Foundation; | ||
|
||
use Vanilo\Foundation\Features\MultiChannel; | ||
|
||
class Features | ||
{ | ||
private static ?MultiChannel $multiChannel = null; | ||
|
||
public static function multichannel(): MultiChannel | ||
{ | ||
return self::$multiChannel ?: (self::$multiChannel = new MultiChannel()); | ||
} | ||
|
||
public static function isMultiChannelEnabled(): bool | ||
{ | ||
return self::multichannel()->isEnabled(); | ||
} | ||
|
||
public static function isMultiChannelDisabled(): bool | ||
{ | ||
return self::multichannel()->isDisabled(); | ||
} | ||
} |
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,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Contains the MultiChannel class. | ||
* | ||
* @copyright Copyright (c) 2023 Vanilo UG | ||
* @author Attila Fulop | ||
* @license MIT | ||
* @since 2023-09-07 | ||
* | ||
*/ | ||
|
||
namespace Vanilo\Foundation\Features; | ||
|
||
use Vanilo\Foundation\Contracts\Feature; | ||
|
||
class MultiChannel implements Feature | ||
{ | ||
public function isEnabled(): bool | ||
{ | ||
return (bool) config('vanilo.foundation.features.multi_channel.is_enabled', false); | ||
} | ||
|
||
public function isDisabled(): bool | ||
{ | ||
return !$this->isEnabled(); | ||
} | ||
|
||
public function configuration(): array | ||
{ | ||
return config('vanilo.foundation.features.multi_channel', []); | ||
} | ||
} |
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