1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace Cocotte\Help; |
4
|
|
|
|
5
|
|
|
use Cocotte\DigitalOcean\ApiToken; |
6
|
|
|
use Cocotte\Template\StaticSite\StaticSiteHostname; |
7
|
|
|
use Cocotte\Template\StaticSite\StaticSiteNamespace; |
8
|
|
|
use Cocotte\Template\Traefik\TraefikHostname; |
9
|
|
|
use Cocotte\Template\Traefik\TraefikPassword; |
10
|
|
|
use Cocotte\Template\Traefik\TraefikUsername; |
11
|
|
|
|
12
|
|
|
final class FromEnvExamples implements CommandExamples |
13
|
|
|
{ |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @var ApiToken |
17
|
|
|
*/ |
18
|
|
|
private $apiToken; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @var TraefikHostname |
22
|
|
|
*/ |
23
|
|
|
private $traefikHostname; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var TraefikUsername |
27
|
|
|
*/ |
28
|
|
|
private $traefikUsername; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var TraefikPassword |
32
|
|
|
*/ |
33
|
|
|
private $traefikPassword; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var StaticSiteHostname |
37
|
|
|
*/ |
38
|
|
|
private $staticSiteHostname; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var StaticSiteNamespace |
42
|
|
|
*/ |
43
|
|
|
private $staticSiteNamespace; |
44
|
|
|
|
45
|
|
|
public function __construct( |
46
|
|
|
ApiToken $apiToken, |
47
|
|
|
TraefikHostname $traefikHostname, |
48
|
|
|
TraefikUsername $traefikUsername, |
49
|
|
|
TraefikPassword $traefikPassword, |
50
|
|
|
StaticSiteHostname $staticSiteHostname, |
51
|
|
|
StaticSiteNamespace $staticSiteNamespace |
52
|
|
|
) { |
53
|
|
|
$this->apiToken = $apiToken; |
54
|
|
|
$this->traefikHostname = $traefikHostname; |
55
|
|
|
$this->traefikUsername = $traefikUsername; |
56
|
|
|
$this->traefikPassword = $traefikPassword; |
57
|
|
|
$this->staticSiteHostname = $staticSiteHostname; |
58
|
|
|
$this->staticSiteNamespace = $staticSiteNamespace; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
public function install(): string |
62
|
|
|
{ |
63
|
|
|
return (new DefaultExamples)->install( |
64
|
|
|
$this->apiToken->toString(), |
65
|
|
|
$this->traefikHostname->toString(), |
66
|
|
|
$this->traefikPassword->toString(), |
67
|
|
|
$this->traefikUsername->toString() |
68
|
|
|
); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
public function staticSite(string $token = null, string $namespace = null, string $hostname = null): string |
72
|
|
|
{ |
73
|
|
|
return (new DefaultExamples)->staticSite( |
74
|
|
|
$token ?? $this->apiToken->toString(), |
75
|
|
|
$namespace ?? $this->staticSiteNamespace->toString(), |
76
|
|
|
$hostname ?? $this->staticSiteHostname->toString() |
77
|
|
|
); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
public function uninstall(): string |
81
|
|
|
{ |
82
|
|
|
return (new DefaultExamples)->uninstall( |
83
|
|
|
$this->apiToken->toString(), |
84
|
|
|
$this->traefikHostname->toString() |
85
|
|
|
); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
public function installInteractive(): string |
89
|
|
|
{ |
90
|
|
|
return (new DefaultExamples)->installInteractive(); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
public function uninstallInteractive(): string |
94
|
|
|
{ |
95
|
|
|
return (new DefaultExamples)->uninstallInteractive(); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
public function staticSiteInteractive(): string |
99
|
|
|
{ |
100
|
|
|
return (new DefaultExamples)->staticSiteInteractive(); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
} |