Files
Investidor-V2/app/Services/InstitutionalLinkMonitor.php
T
nala 1106509116
tests / ci (push) Canceled after 0s
vrsao 2
2026-10-08 14:02:01 +02:00

21 lines
944 B
PHP

<?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.')];
}
}