ConfigServiceProvider.php
1.1 KB
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
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Service;
use Yansongda\Pay\Contract\ConfigInterface;
use Yansongda\Pay\Contract\ServiceProviderInterface;
use Yansongda\Pay\Exception\ContainerException;
use Yansongda\Pay\Pay;
use Yansongda\Supports\Config;
class ConfigServiceProvider implements ServiceProviderInterface
{
private array $config = [
'logger' => [
'enable' => false,
'file' => null,
'identify' => 'yansongda.pay',
'level' => 'debug',
'type' => 'daily',
'max_files' => 30,
],
'http' => [
'timeout' => 5.0,
'connect_timeout' => 3.0,
'headers' => [
'User-Agent' => 'yansongda/pay-v3',
],
],
'mode' => Pay::MODE_NORMAL,
];
/**
* @param mixed $data
*
* @throws ContainerException
*/
public function register($data = null): void
{
$config = new Config(array_replace_recursive($this->config, $data ?? []));
Pay::set(ConfigInterface::class, $config);
}
}