WIP on PHP 8.4 conversion
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace MyPrayerJournal\Domain;
|
||||
|
||||
use BitBadger\InspiredByFSharp\Option;
|
||||
use BitBadger\PDODocument\DocumentException;
|
||||
|
||||
/**
|
||||
@@ -24,7 +25,6 @@ class Note
|
||||
*/
|
||||
public static function byRequestId(string $id): array
|
||||
{
|
||||
$req = Request::byId($id);
|
||||
return $req->isDefined() ? $req->get()->notes : [];
|
||||
return Request::byId($id)->map(fn(Request $it) => Option::Some($it->notes))->getOrDefault([]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
|
||||
namespace MyPrayerJournal\Domain;
|
||||
|
||||
use BitBadger\InspiredByFSharp\Option;
|
||||
use BitBadger\PDODocument\{Custom, DocumentException, DocumentList, Find};
|
||||
use BitBadger\PDODocument\Mapper\DocumentMapper;
|
||||
use DateTimeImmutable;
|
||||
use Exception;
|
||||
use JsonSerializable;
|
||||
use MyPrayerJournal\Table;
|
||||
use PhpOption\{None, Option};
|
||||
|
||||
/**
|
||||
* A prayer request
|
||||
@@ -111,8 +111,8 @@ class Request implements JsonSerializable
|
||||
*/
|
||||
public static function byId(string $id): Option
|
||||
{
|
||||
$req = Find::byId(Table::REQUEST, $id, self::class);
|
||||
return ($req->getOrElse(new Request('x'))->userId == $_SESSION['user_id']) ? $req : None::create();
|
||||
return Find::byId(Table::REQUEST, $id, self::class)
|
||||
->map(fn(Request $it) => $it->userId === $_SESSION['user_id'] ? Option::Some($it) : Option::None());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -187,7 +187,7 @@ class Request implements JsonSerializable
|
||||
*/
|
||||
public static function answered(): DocumentList
|
||||
{
|
||||
return self::forUser(false);
|
||||
return self::forUser(active: false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user