-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathFeatures.php
103 lines (82 loc) · 2.34 KB
/
Features.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?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\Contracts\Feature;
use Vanilo\Support\Features\Inventory;
use Vanilo\Support\Features\MultiChannel;
use Vanilo\Support\Features\Pricing;
use Vanilo\Support\Features\SearchEngine;
class Features
{
private static ?MultiChannel $multiChannel = null;
private static ?Pricing $pricing = null;
private static ?SearchEngine $searchEngine = null;
private static ?Inventory $inventory = null;
public static function findByName(string $name): ?Feature
{
return match ($name) {
'pricing' => self::pricing(),
'multichannel' => self::multichannel(),
'search_engine' => self::searchEngine(),
'inventory' => self::inventory(),
default => null,
};
}
public static function multichannel(): MultiChannel
{
return self::$multiChannel ??= new MultiChannel();
}
public static function pricing(): Pricing
{
return self::$pricing ??= new Pricing();
}
public static function inventory(): Inventory
{
return self::$inventory ??= new Inventory();
}
public static function searchEngine(): SearchEngine
{
return self::$searchEngine ??= new SearchEngine();
}
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();
}
public static function isSearchEngineEnabled(): bool
{
return self::searchEngine()->isEnabled();
}
public static function isSearchEngineDisabled(): bool
{
return self::searchEngine()->isDisabled();
}
public static function isInventoryEnabled(): bool
{
return self::inventory()->isEnabled();
}
public static function isInventoryDisabled(): bool
{
return self::inventory()->isDisabled();
}
}