Skip to content

Commit

Permalink
Moved the Features functionality from Foundation to Support
Browse files Browse the repository at this point in the history
  • Loading branch information
fulopattila122 committed Feb 19, 2024
1 parent d0804b8 commit b62feae
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

- Dropped PHP 8.0 & PHP 8.1 Support
- Dropped Laravel 9 Support
- Added the `Features` accessor class, which is a syntactic sugar for areas of the configuration

## 3.x Series

Expand Down
55 changes: 55 additions & 0 deletions Features.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?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\Support;

use Vanilo\Support\Features\MultiChannel;
use Vanilo\Support\Features\Pricing;

class Features
{
private static ?MultiChannel $multiChannel = null;

private static ?Pricing $pricing = null;

public static function multichannel(): MultiChannel
{
return self::$multiChannel ?: (self::$multiChannel = new MultiChannel());
}

public static function pricing(): Pricing
{
return self::$pricing ?: (self::$pricing = new Pricing());
}

public static function isMultiChannelEnabled(): bool
{
return self::multichannel()->isEnabled();
}

public static function isMultiChannelDisabled(): bool
{
return self::multichannel()->isDisabled();
}

public static function isPricingEnabled(): bool
{
return self::pricing()->isEnabled();
}

public static function isPricingDisabled(): bool
{
return self::pricing()->isDisabled();
}
}
35 changes: 35 additions & 0 deletions Features/MultiChannel.php
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\Support\Features;

use Vanilo\Contracts\Feature;

class MultiChannel implements Feature
{
public function isEnabled(): bool
{
return (bool) config('vanilo.features.multi_channel.is_enabled', false);
}

public function isDisabled(): bool
{
return !$this->isEnabled();
}

public function configuration(): array
{
return config('vanilo.foundation.features.multi_channel', []);
}
}
36 changes: 36 additions & 0 deletions Features/Pricing.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

declare(strict_types=1);

/**
* Contains the Pricing class.
*
* @copyright Copyright (c) 2024 Vanilo UG
* @author Attila Fulop
* @license MIT
* @since 2024-01-18
*
*/

namespace Vanilo\Support\Features;

use Vanilo\Contracts\Feature;

class Pricing implements Feature
{
public function isEnabled(): bool
{
return config('vanilo.foundation.features.pricing.is_enabled', false)
&& null !== concord()->module('vanilo.pricing');
}

public function isDisabled(): bool
{
return !$this->isEnabled();
}

public function configuration(): array
{
return config('vanilo.foundation.features.pricing', []);
}
}

0 comments on commit b62feae

Please sign in to comment.