add flat file impl with find by email, save not implemented yet

This commit is contained in:
Yisroel Baum 2025-11-02 09:41:11 +02:00
parent 7d21ce97e9
commit a64a2103e1
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9

View file

@ -0,0 +1,23 @@
<?php
namespace FreightQuote\User;
class FlatFileUserRepository implements UserRepository
{
private string $pathToUserFile = __DIR__.'/../../storage/users.json';
public function findByEmail(string $email): ?User
{
$json = file_get_contents($this->pathToUserFile);
$data = json_decode($json, true);
foreach ($data as $user) {
if ($user['email'] === $email) {
return new User($user['email'], $user['password']);
}
}
}
public function save(User $user): User
{
}
}