Closes Module 1: 9 auth endpoints under /api/v1/auth, OTP via SMS (Semaphore + log + fake drivers), role middleware, role + admin seeders, 27 feature tests passing. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
36 lines
819 B
PHP
36 lines
819 B
PHP
<?php
|
|
|
|
namespace App\Services\Sms;
|
|
|
|
use Illuminate\Support\Collection;
|
|
use Illuminate\Support\Str;
|
|
|
|
class FakeSmsService implements SmsService
|
|
{
|
|
/** @var Collection<int, array{to: string, message: string, id: string}> */
|
|
public Collection $messages;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->messages = collect();
|
|
}
|
|
|
|
public function send(string $to, string $message): SmsResult
|
|
{
|
|
$id = (string) Str::uuid();
|
|
$this->messages->push(['to' => $to, 'message' => $message, 'id' => $id]);
|
|
|
|
return SmsResult::success($id);
|
|
}
|
|
|
|
public function lastMessageTo(string $to): ?string
|
|
{
|
|
return $this->messages->last(fn ($m) => $m['to'] === $to)['message'] ?? null;
|
|
}
|
|
|
|
public function reset(): void
|
|
{
|
|
$this->messages = collect();
|
|
}
|
|
}
|