*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see
ERROR: (' . $code . ') ' . $description . '
'; } private static function jsonError($code, $description): bool|string { return json_encode([ 'success' => false, 'errorcode' => $code, 'description' => $description, ], JSON_PRETTY_PRINT); } private static function textError($code, $description): string { return 'ERROR: (' . $code . ') ' . $description; } public function send($files): void { $response = match ($this->type) { 'csv' => $this->csvSuccess($files), 'html' => $this->htmlSuccess($files), 'json' => $this->jsonSuccess($files), 'text' => $this->textSuccess($files), }; http_response_code(200); // "200 OK". Success. echo $response; } private static function csvSuccess($files): string { $result = '"name","url","hash","size"' . "\r\n"; foreach ($files as $file) { $result .= '"' . $file['name'] . '"' . ',' . '"' . $file['url'] . '"' . ',' . '"' . $file['hash'] . '"' . ',' . '"' . $file['size'] . '"' . "\r\n"; } return $result; } private static function htmlSuccess($files): string { $result = ''; foreach ($files as $file) { $result .= '' . $file['url'] . '