|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Jabe\Engine\Impl\Telemetry\Dto; |
|
4
|
|
|
|
|
5
|
|
|
use Jabe\Engine\Telemetry\{ |
|
6
|
|
|
ApplicationServerInterface, |
|
7
|
|
|
DatabaseInterface, |
|
8
|
|
|
InternalsInterface, |
|
9
|
|
|
LicenseKeyDataInterface |
|
10
|
|
|
}; |
|
11
|
|
|
|
|
12
|
|
|
class InternalsImpl implements InternalsInterface |
|
13
|
|
|
{ |
|
14
|
|
|
public const SERIALIZED_APPLICATION_SERVER = "application-server"; |
|
15
|
|
|
public const SERIALIZED_INTEGRATION = "integration"; |
|
16
|
|
|
public const SERIALIZED_LICENSE_KEY = "license-key"; |
|
17
|
|
|
public const SERIALIZED_TELEMETRY_ENABLED = "telemetry-enabled"; |
|
18
|
|
|
|
|
19
|
|
|
protected $database; |
|
20
|
|
|
protected $applicationServer; |
|
21
|
|
|
protected $licenseKey; |
|
22
|
|
|
protected $commands = []; |
|
23
|
|
|
protected $integration = []; |
|
24
|
|
|
protected $metrics = []; |
|
25
|
|
|
protected $webapps = []; |
|
26
|
|
|
|
|
27
|
|
|
protected $telemetryEnabled; |
|
28
|
|
|
|
|
29
|
|
|
public function __construct(/*DatabaseImpl|InternalsImpl*/$databaseOrOnternals, ApplicationServerInterface $server = null, LicenseKeyDataInterface $licenseKey = null) |
|
|
|
|
|
|
30
|
|
|
{ |
|
31
|
|
|
if ($databaseOrInternals instanceof DatabaseInterface) { |
|
|
|
|
|
|
32
|
|
|
$this->database = $databaseOrInternals; |
|
33
|
|
|
$this->applicationServer = $server; |
|
34
|
|
|
$this->licenseKey = $licenseKey; |
|
35
|
|
|
} elseif ($databaseOrInternals instanceof InternalsInterface) { |
|
36
|
|
|
$this->database = $databaseOrInternals->database; |
|
|
|
|
|
|
37
|
|
|
$this->applicationServer = $databaseOrInternals->applicationServer; |
|
|
|
|
|
|
38
|
|
|
$this->licenseKey = $databaseOrInternals->licenseKey; |
|
|
|
|
|
|
39
|
|
|
$this->integration = $databaseOrInternals->getIntegration(); |
|
40
|
|
|
$this->commands = $databaseOrInternals->getCommands(); |
|
41
|
|
|
$this->metrics = $databaseOrInternals->getMetrics(); |
|
42
|
|
|
$this->telemetryEnabled = $databaseOrInternals->telemetryEnabled; |
|
|
|
|
|
|
43
|
|
|
$this->webapps = $databaseOrInternals->webapps; |
|
|
|
|
|
|
44
|
|
|
} |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
public function __toString() |
|
48
|
|
|
{ |
|
49
|
|
|
$commands = []; |
|
50
|
|
|
foreach ($this->commands as $command) { |
|
51
|
|
|
$commands[] = json_decode($command); |
|
52
|
|
|
} |
|
53
|
|
|
$integrations = []; |
|
54
|
|
|
foreach ($this->integration as $integration) { |
|
55
|
|
|
$integrations[] = json_decode($integration); |
|
56
|
|
|
} |
|
57
|
|
|
return json_encode([ |
|
58
|
|
|
'database' => json_decode($this->database), |
|
59
|
|
|
'applicationServer' => json_decode($this->applicationServer), |
|
60
|
|
|
'licenseKey' => json_decode($this->licenseKey), |
|
61
|
|
|
'commands' => $commands, |
|
62
|
|
|
'integration' => $integrations |
|
63
|
|
|
]); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
public function getDatabase(): DatabaseInterface |
|
67
|
|
|
{ |
|
68
|
|
|
return $this->database; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
public function setDatabase(DatabaseInterface $database): void |
|
72
|
|
|
{ |
|
73
|
|
|
$this->database = $database; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
public function getApplicationServer(): ApplicationServerInterface |
|
77
|
|
|
{ |
|
78
|
|
|
return $this->applicationServer; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
public function setApplicationServer(ApplicationServerInterface $applicationServer): void |
|
82
|
|
|
{ |
|
83
|
|
|
$this->applicationServer = $applicationServer; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
public function getCommands(): array |
|
87
|
|
|
{ |
|
88
|
|
|
return $this->commands; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
public function setCommands(array $commands): void |
|
92
|
|
|
{ |
|
93
|
|
|
$this->commands = $commands; |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
public function getMetrics(): array |
|
97
|
|
|
{ |
|
98
|
|
|
return $this->metrics; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
public function setMetrics(array $metrics): void |
|
102
|
|
|
{ |
|
103
|
|
|
$this->metrics = $metrics; |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
public function mergeDynamicData(InternalsInterface $other): void |
|
107
|
|
|
{ |
|
108
|
|
|
$this->commands = $other->commands; |
|
|
|
|
|
|
109
|
|
|
$this->metrics = $other->metrics; |
|
|
|
|
|
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
public function getIntegration(): array |
|
113
|
|
|
{ |
|
114
|
|
|
return $this->integration; |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
public function setIntegration(array $integration): void |
|
118
|
|
|
{ |
|
119
|
|
|
$this->integration = $integration; |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
public function getLicenseKey(): LicenseKeyDataInterface |
|
123
|
|
|
{ |
|
124
|
|
|
return $this->licenseKey; |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
public function setLicenseKey(LicenseKeyDataInterface $licenseKey): void |
|
128
|
|
|
{ |
|
129
|
|
|
$this->licenseKey = $licenseKey; |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
public function getTelemetryEnabled(): bool |
|
133
|
|
|
{ |
|
134
|
|
|
return $this->telemetryEnabled; |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
public function setTelemetryEnabled(bool $telemetryEnabled): void |
|
138
|
|
|
{ |
|
139
|
|
|
$this->telemetryEnabled = $telemetryEnabled; |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
|
|
public function getWebapps(): array |
|
143
|
|
|
{ |
|
144
|
|
|
return $this->webapps; |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
|
|
public function setWebapps(array $webapps): void |
|
148
|
|
|
{ |
|
149
|
|
|
$this->webapps = $webapps; |
|
150
|
|
|
} |
|
151
|
|
|
} |
|
152
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.