Replace to_option with Option::of
This commit is contained in:
parent
8cf84f1450
commit
42870bf419
5
src/composer.lock
generated
5
src/composer.lock
generated
@ -12,12 +12,13 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://git.bitbadger.solutions/bit-badger/inspired-by-fsharp",
|
||||
"reference": "193147cfb32f423dceb1619f091445efa1a2f13e"
|
||||
"reference": "7d25b9ea282c1e244fec6e14a1e1b251314824e4"
|
||||
},
|
||||
"require": {
|
||||
"php": "^8"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpoption/phpoption": "^1",
|
||||
"phpunit/phpunit": "^11"
|
||||
},
|
||||
"default-branch": true,
|
||||
@ -49,7 +50,7 @@
|
||||
"rss": "https://git.bitbadger.solutions/bit-badger/inspired-by-fsharp.rss",
|
||||
"source": "https://git.bitbadger.solutions/bit-badger/inspired-by-fsharp"
|
||||
},
|
||||
"time": "2024-07-27T02:55:02+00:00"
|
||||
"time": "2024-07-28T01:20:35+00:00"
|
||||
},
|
||||
{
|
||||
"name": "bit-badger/pdo-document",
|
||||
|
@ -299,7 +299,7 @@ class Feed
|
||||
*/
|
||||
public static function retrieveById(int $feedId): Option
|
||||
{
|
||||
return to_option(
|
||||
return Option::of(
|
||||
Find::byId(Table::Feed, $feedId, static::class)
|
||||
->filter(fn($it) => $it->user_id === $_SESSION[Key::UserId]));
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ class ItemWithFeed extends Item
|
||||
public static function retrieveById(int $id): Option
|
||||
{
|
||||
$fields = self::idAndUserFields($id);
|
||||
return to_option(
|
||||
return Option::of(
|
||||
Custom::single(self::SELECT_WITH_FEED . ' WHERE ' . Query::whereByFields($fields),
|
||||
Parameters::addFields($fields, []), new DocumentMapper(self::class)));
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ class User
|
||||
*/
|
||||
public static function findByEmail(string $email): Option
|
||||
{
|
||||
return to_option(Find::firstByFields(Table::User, [Field::EQ('email', $email)], User::class));
|
||||
return Option::of(Find::firstByFields(Table::User, [Field::EQ('email', $email)], User::class));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -187,14 +187,3 @@ function not_found(): never
|
||||
http_response_code(404);
|
||||
die('Not Found');
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform a `PhpOption` into the option we use
|
||||
*
|
||||
* @param \PhpOption\Option $option The option to be transformed
|
||||
* @return Option An option in the form Feed Reader Central uses
|
||||
*/
|
||||
function to_option(PhpOption\Option $option): Option
|
||||
{
|
||||
return $option->isDefined() ? Option::Some($option->get()) : Option::None();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user