-
Notifications
You must be signed in to change notification settings - Fork 0
/
Config.php
49 lines (42 loc) · 1.21 KB
/
Config.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
<?php
declare(strict_types=1);
/**
* This file is part of MineAdmin.
*
* @link https://www.mineadmin.com
* @document https://doc.mineadmin.com
* @contact [email protected]
* @license https://github.com/mineadmin/MineAdmin/blob/master/LICENSE
*/
namespace Mine\GeneratorCrud;
use Hyperf\Contract\ConfigInterface;
use Mine\GeneratorCrud\Processor\ProcessorInterface;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\ContainerInterface;
use Psr\Container\NotFoundExceptionInterface;
final class Config
{
public function __construct(
private readonly ConfigInterface $config,
private readonly ContainerInterface $container
) {}
public function getConfig(): ConfigInterface
{
return $this->config;
}
public function isEnable(): bool
{
return (bool) $this->config->get('generator.enable', false);
}
/**
* @return iterable<ProcessorInterface>
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function getProcessors(): iterable
{
foreach ($this->config->get('generator.processors', []) as $processor) {
yield $this->container->get($processor);
}
}
}