Page MenuHomeDevCentral

No OneTemporary

diff --git a/composer.json b/composer.json
index 00e33f7..9967bad 100644
--- a/composer.json
+++ b/composer.json
@@ -1,26 +1,26 @@
{
"name": "nasqueron/api-serverslog",
"description": "Serve the servers log API",
"type": "project",
"license": "BSD-2-Clause",
"authors": [
{
"name": "Sébastien Santoro",
"email": "dereckson@espace-win.org"
}
],
"require": {
"php": ">=7.3.0",
"netresearch/jsonmapper": "^4.1.0",
- "vlucas/phpdotenv": "^2.4"
+ "vlucas/phpdotenv": "^5.6"
},
"require-dev": {
- "phpunit/phpunit": "^9.5"
+ "phpunit/phpunit": "^12"
},
"autoload": {
"psr-4": {
"Nasqueron\\Api\\ServersLog\\": "src/",
"Nasqueron\\Api\\ServersLog\\Tests\\": "tests/"
}
}
}
diff --git a/src/Service.php b/src/Service.php
index a02220b..a8d7069 100644
--- a/src/Service.php
+++ b/src/Service.php
@@ -1,75 +1,75 @@
<?php
namespace Nasqueron\Api\ServersLog;
use Dotenv\Dotenv;
class Service extends BaseService {
///
/// Initialisation
///
public function __construct () {
$this->loadEnvironment();
}
///
/// Controller
///
private function isAliveRequest() : bool {
return
$_SERVER['REQUEST_METHOD'] === "GET"
&&
$_SERVER['REQUEST_URI'] === '/status';
}
public function handle () : void {
if ($this->isAliveRequest()) {
$this->sendSuccessResponse("ALIVE");
} elseif ($_SERVER['REQUEST_METHOD'] === "PUT") {
$body = $this->getBodyObject();
$this->put($body);
} else {
$this->sendInvalidMethodResponse();
}
}
public function put ($data) : void {
if ($data === NULL) {
$this->sendBadRequestResponse();
return;
}
$log = self::getServersLogFile();
if (!$log) {
$this->sendInternalServerError();
return;
}
Log::addEntryToJSONFile(
$log,
LogEntry::fromJSON($data)
);
$this->sendSuccessResponse();
}
///
/// Helper methods
///
private function loadEnvironment () : void {
- $env = new Dotenv(__DIR__);
+ $env = Dotenv::createUnsafeImmutable(__DIR__);
if (file_exists(__DIR__ . '/.env')) {
$env->load();
}
$env->required('SERVERS_LOG_FILE');
}
private static function getServersLogFile () : string {
return getenv('SERVERS_LOG_FILE');
}
}

File Metadata

Mime Type
text/x-diff
Expires
Sat, Nov 14, 19:16 (6 d, 12 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4246199
Default Alt Text
(2 KB)

Event Timeline