Total Complexity | 4 |
Total Lines | 69 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
8 | class Config |
||
9 | { |
||
10 | /** |
||
11 | * Default webhook config directory. |
||
12 | */ |
||
13 | public const CONF_DIR = 'webhooks.'; |
||
14 | |||
15 | /** |
||
16 | * Default webhook request key. |
||
17 | */ |
||
18 | public const REQUEST_URI = 'request'; |
||
19 | |||
20 | /** |
||
21 | * Http configuration parameters. |
||
22 | * |
||
23 | * @var array |
||
24 | */ |
||
25 | public array $configs; |
||
26 | |||
27 | /** |
||
28 | * WebHook configuration parameters. |
||
29 | * |
||
30 | * @var array |
||
31 | */ |
||
32 | public array $hooks; |
||
33 | |||
34 | /** |
||
35 | * Configuration parameters. |
||
36 | * |
||
37 | * @var Collection |
||
38 | */ |
||
39 | private Collection $configurable; |
||
40 | 3 | ||
41 | public function __construct($config) |
||
42 | 3 | { |
|
43 | if (is_string($config)) { |
||
44 | 3 | $config = config($config, config(self::CONF_DIR . $config, [])); |
|
45 | 2 | } |
|
46 | 2 | ||
47 | $this->configurable = new Collection($config); |
||
48 | |||
49 | 1 | $this->configs = $this->excludeBodyConfig(); |
|
50 | |||
51 | $this->hooks = $this->configurable->get(self::REQUEST_URI, []); |
||
52 | 2 | } |
|
53 | 2 | ||
54 | /** |
||
55 | * Exclude configurable from body |
||
56 | */ |
||
57 | protected function excludeBodyConfig(): array |
||
67 | } |
||
68 | |||
69 | /** |
||
70 | * Provide configuration parameter as array. |
||
71 | * |
||
72 | * @return array |
||
73 | 2 | */ |
|
74 | public function toArray(): array |
||
79 |