Run php-cs-fixer on src

This commit is contained in:
2025-12-17 04:25:47 +09:00
parent 0a77f46fe1
commit f782d20e56
19 changed files with 237 additions and 264 deletions
+13 -14
View File
@@ -4,23 +4,22 @@ declare(strict_types=1);
namespace pvv\side;
use PDO;
class MOTD {
private $pdo;
public function __construct(PDO $pdo) {
public function __construct(\PDO $pdo) {
$this->pdo = $pdo;
}
public function setMOTD(string $title, string $content): void {
if (\is_array($content)) {
$content = implode("_", $content);
$content = implode('_', $content);
}
$query = "INSERT INTO motd(title, content) VALUES (:title, :content);";
$query = 'INSERT INTO motd(title, content) VALUES (:title, :content);';
$statement = $this->pdo->prepare($query);
$statement->bindParam(":title", $title, \PDO::PARAM_STR);
$statement->bindParam(":content", $content, \PDO::PARAM_STR);
$statement->bindParam(':title', $title, \PDO::PARAM_STR);
$statement->bindParam(':content', $content, \PDO::PARAM_STR);
$statement->execute();
}
@@ -29,28 +28,28 @@ class MOTD {
* @return array{title: string, content: string[]}
*/
public function getMOTD(): array {
$query =
"SELECT motd.title, motd.content FROM motd ORDER BY motd.id DESC LIMIT 1";
$query
= 'SELECT motd.title, motd.content FROM motd ORDER BY motd.id DESC LIMIT 1';
$statement = $this->pdo->prepare($query);
$statement->execute();
$data = $statement->fetch();
return ["title" => $data[0], "content" => explode("\n", $data[1])];
return ['title' => $data[0], 'content' => explode("\n", $data[1])];
}
/**
* @return array{title: string, content: string[]}
*/
public function getMOTD_history(int $limit = 5): array {
$query =
"SELECT motd.title, motd.content FROM motd ORDER BY motd.id DESC LIMIT :limit";
$query
= 'SELECT motd.title, motd.content FROM motd ORDER BY motd.id DESC LIMIT :limit';
$statement = $this->pdo->prepare($query);
$statement->bindParam(":limit", $limit, \PDO::PARAM_STR);
$statement->bindParam(':limit', $limit, \PDO::PARAM_STR);
$statement->execute();
$data = $statement->fetch();
return ["title" => $data[0], "content" => explode("\n", $data[1])];
return ['title' => $data[0], 'content' => explode("\n", $data[1])];
}
}