Automated PR provided by Codex via Gitea API. Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #475
21 lines
416 B
PHP
21 lines
416 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Support\Pdf;
|
|
|
|
final class PdfByteValidator
|
|
{
|
|
public static function isValid(string $bytes): bool
|
|
{
|
|
if ($bytes === '' || ! str_starts_with($bytes, '%PDF-')) {
|
|
return false;
|
|
}
|
|
|
|
$trimmedBytes = rtrim($bytes);
|
|
|
|
return str_contains($trimmedBytes, 'startxref')
|
|
&& str_ends_with($trimmedBytes, '%%EOF');
|
|
}
|
|
}
|