-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathConfigBuilder.php
72 lines (59 loc) · 1.47 KB
/
ConfigBuilder.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
<?php
declare(strict_types=1);
namespace Abrouter\Client\Builders;
use Abrouter\Client\Config\Config;
use Abrouter\Client\Config\ParallelRunConfig;
use Abrouter\Client\Contracts\KvStorageContract;
class ConfigBuilder
{
private const DEFAULT_HOST = 'https://abrouter.com';
/**
* @var string $host
*/
private string $host;
/**
* @var string $token
*/
private string $token;
private ?ParallelRunConfig $parallelRunConfig = null;
private ?KvStorageContract $kvStorageContract = null;
/**
* @param string $host
*
* @return ConfigBuilder
*/
public function setHost(string $host): self
{
$this->host = $host;
return $this;
}
/**
* @param string $token
*
* @return ConfigBuilder
*/
public function setToken(string $token): self
{
$this->token = $token;
return $this;
}
public function setParallelRunConfig(ParallelRunConfig $parallelRunConfig): self
{
$this->parallelRunConfig = $parallelRunConfig;
return $this;
}
public function setKvStorage(KvStorageContract $kvStorageContract): self
{
$this->kvStorageContract = $kvStorageContract;
return $this;
}
public function build(): Config
{
return new Config(
$this->token,
$this->host ?? self::DEFAULT_HOST,
$this->parallelRunConfig,
$this->kvStorageContract
);
}
}