Skip to content

Commit b1a5d67

Browse files
Fixes
1 parent d025b05 commit b1a5d67

3 files changed

Lines changed: 20 additions & 8 deletions

File tree

src/Observability/SentryLogger.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function initialize(object $config): void
3333

3434
private function getEnvironment(): string
3535
{
36-
if ($_SERVER['SERVER_NAME'] === 'localhost') {
36+
if (!isset($_SERVER['SERVER_NAME']) || $_SERVER['SERVER_NAME'] === 'localhost') {
3737
return 'development';
3838
}
3939

src/Observability/SimpleFileIO.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ final class SimpleFileIO {
99
public function writeActivationFile(BluemConfiguration $data): bool
1010
{
1111
$path = __DIR__ . '/../../logs/';
12-
$filename = "activations_" . date("Ymd") . ".json";
12+
$filename = $this->createFileName();
1313

1414
try {
1515
$fileContent = json_encode($data, JSON_THROW_ON_ERROR) . "\r\n";
@@ -23,10 +23,15 @@ public function writeActivationFile(BluemConfiguration $data): bool
2323
public function activationFileExists(): bool
2424
{
2525
$path = __DIR__ . '/../../logs/';
26-
# consider a new file every month
27-
$filename = "activations_" . date("Ym") . ".json";
26+
$filename = $this->createFileName();
2827

2928
return file_exists($path . $filename);
3029
}
30+
31+
# consider a new file every month
32+
private function createFileName(): string
33+
{
34+
return "activations_" . date("Ym") . ".json";
35+
}
3136
}
3237

src/Observability/SimpleMailer.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,25 @@ public function notifyConfiguration(object $configuration): bool {
99
foreach ($configuration as $key => $value) {
1010
$message .= strtoupper($key) . ": " . $value . "\n";
1111
}
12-
$message .= "Environment: ". $_SERVER['SERVER_NAME'] === 'localhost' ? 'development' : 'production';
12+
$message .= "Environment: ". $this->getEnvironment();
13+
14+
$adminEmail = "pluginsupport@bluem.nl";
1315

1416
// Additional headers
15-
$headers = "From: sender@example.com\r\n";
16-
$headers .= "Reply-To: sender@example.com\r\n";
17+
$headers = "From: $adminEmail\r\n";
18+
$headers .= "Reply-To: $adminEmail\r\n";
1719
$headers .= "X-Mailer: PHP/" . phpversion();
1820

19-
$to = "pluginsupport@bluem.nl";
21+
$to = $adminEmail;
2022
$subject = "Library Bluem-php instantiatie";
2123

2224
// Send the email
2325
return mail($to, $subject, $message, $headers);
2426
}
27+
28+
private function getEnvironment()
29+
{
30+
return (!isset($_SERVER['SERVER_NAME']) || $_SERVER['SERVER_NAME'] === 'localhost' ? 'development' : 'production');
31+
}
2532
}
2633

0 commit comments

Comments
 (0)