Formatted with php-cs-fixer
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use RedBeanPHP\R;
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
<?php
|
||||
|
||||
// Non utilisé pour l'instant
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Models;
|
||||
@@ -9,7 +10,7 @@ use RedBeanPHP\OODBBean;
|
||||
/**
|
||||
* Modèle RedBeanPHP minimal pour l'entité « post ».
|
||||
*
|
||||
* Chaque instance encapsule un bean RedBean (`OODBBean`).
|
||||
* Chaque instance encapsule un bean RedBean (`OODBBean`).
|
||||
* Les opérations CRUD sont déléguées à RedBean, tandis que les
|
||||
* getters/setters offrent une API typée.
|
||||
*/
|
||||
@@ -51,7 +52,7 @@ class Post
|
||||
public static function allDesc(): array
|
||||
{
|
||||
$beans = R::findAll('post', ' ORDER BY id DESC ');
|
||||
return array_map(fn(OODBBean $b) => new self($b), $beans);
|
||||
return array_map(fn (OODBBean $b) => new self($b), $beans);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------
|
||||
@@ -74,12 +75,27 @@ class Post
|
||||
ACCESSEURS / MUTATEURS
|
||||
------------------------------------------------- */
|
||||
|
||||
public function getId(): int { return (int) $this->bean->id; }
|
||||
public function getTitle(): string { return (string) $this->bean->title; }
|
||||
public function getContent(): string { return (string) $this->bean->content; }
|
||||
public function getId(): int
|
||||
{
|
||||
return (int) $this->bean->id;
|
||||
}
|
||||
public function getTitle(): string
|
||||
{
|
||||
return (string) $this->bean->title;
|
||||
}
|
||||
public function getContent(): string
|
||||
{
|
||||
return (string) $this->bean->content;
|
||||
}
|
||||
|
||||
public function setTitle(string $title): void { $this->bean->title = $title; }
|
||||
public function setContent(string $content): void { $this->bean->content = $content; }
|
||||
public function setTitle(string $title): void
|
||||
{
|
||||
$this->bean->title = $title;
|
||||
}
|
||||
public function setContent(string $content): void
|
||||
{
|
||||
$this->bean->content = $content;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------
|
||||
MISE À JOUR À PARTIR D'UN TABLEAU
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Slim\App;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Slim\App;
|
||||
@@ -12,6 +13,6 @@ use App\Controllers\PostController;
|
||||
*/
|
||||
|
||||
return function (App $app): void {
|
||||
// Page d'accueil – liste des articles
|
||||
$app->get('/', [PostController::class, 'index']);
|
||||
// Page d'accueil – liste des articles
|
||||
$app->get('/', [PostController::class, 'index']);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user