@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
/** Availability evidence is distinct from legal validity or institutional endorsement. */
|
||||
class InstitutionalLinkMonitor
|
||||
{
|
||||
/** @return array{available:bool,reason:string,contact:string} */
|
||||
public function status(\stdClass $link): array
|
||||
{
|
||||
$valid = filter_var($link->url, FILTER_VALIDATE_URL) && parse_url($link->url, PHP_URL_SCHEME) === 'https';
|
||||
$fresh = $link->verified_at && Carbon::parse($link->verified_at)->between(now()->subDays(7), now());
|
||||
|
||||
return ['available' => (bool) ($valid && $fresh && $link->status === 'active'),
|
||||
'reason' => ! $valid ? 'invalid_url' : (! $fresh ? 'verification_missing_or_expired' : ($link->status === 'active' ? 'recent_internal_check' : 'reported_unavailable')),
|
||||
'contact' => $link->contact ?: (config('portal.support.email') ?: 'Utilize o pedido de apoio no mesmo dossier.')];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user