parent
04cbe54dd1
commit
220c0ece82
18 changed files with 95 additions and 22 deletions
|
|
@ -4,6 +4,29 @@ declare(strict_types=1);
|
|||
|
||||
final class Ids
|
||||
{
|
||||
public static function validRna(string $value): bool
|
||||
{
|
||||
$value = strtoupper(preg_replace('/\s+/', '', trim($value)) ?? '');
|
||||
return $value === '' || preg_match('/^W[0-9]{9}$/', $value) === 1;
|
||||
}
|
||||
|
||||
public static function validSiret(string $value): bool
|
||||
{
|
||||
$digits = preg_replace('/\D+/', '', trim($value)) ?? '';
|
||||
if ($digits === '') {
|
||||
return true;
|
||||
}
|
||||
if (strlen($digits) !== 14) {
|
||||
return false;
|
||||
}
|
||||
$sum = 0;
|
||||
foreach (str_split($digits) as $index => $digit) {
|
||||
$number = (int) $digit * ($index % 2 === 0 ? 2 : 1);
|
||||
$sum += $number > 9 ? $number - 9 : $number;
|
||||
}
|
||||
return $sum % 10 === 0;
|
||||
}
|
||||
|
||||
public static function slugifyUpper(string $s): string
|
||||
{
|
||||
$s = trim($s);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,14 @@ final class ImageService
|
|||
{
|
||||
private const ALLOWED = ['image/jpeg' => 'jpg', 'image/png' => 'png', 'image/webp' => 'webp', 'image/gif' => 'gif'];
|
||||
|
||||
public static function processor(): ?string
|
||||
{
|
||||
if (self::magickBinary() !== null) {
|
||||
return 'ImageMagick';
|
||||
}
|
||||
return extension_loaded('gd') ? 'GD' : null;
|
||||
}
|
||||
|
||||
public static function inspect(string $path, int $maxBytes = 20_000_000): array
|
||||
{
|
||||
if (!is_file($path) || filesize($path) > $maxBytes) {
|
||||
|
|
|
|||
|
|
@ -57,17 +57,14 @@ final class InstallationService
|
|||
? 'Connecteurs externes disponibles'
|
||||
: 'Extension cURL absente : I-CAD et géocodage indisponibles',
|
||||
);
|
||||
$imageProcessor = ImageService::processor();
|
||||
self::add(
|
||||
$checks,
|
||||
'image',
|
||||
extension_loaded('imagick') || extension_loaded('gd'),
|
||||
$imageProcessor !== null,
|
||||
'recommended',
|
||||
'Traitement des images',
|
||||
extension_loaded('imagick')
|
||||
? 'ImageMagick disponible'
|
||||
: (extension_loaded('gd')
|
||||
? 'GD disponible'
|
||||
: 'ImageMagick ou GD conseillé'),
|
||||
$imageProcessor !== null ? $imageProcessor . ' disponible' : 'ImageMagick ou GD conseillé',
|
||||
);
|
||||
if ($withFilesystem) {
|
||||
foreach (self::directories() as $key => $path) {
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ final class SystemHealthService
|
|||
);
|
||||
$backups = BackupService::list();
|
||||
if (!$backups) {
|
||||
$checks[] = self::check('error', 'continuity', t('health.last_backup'), t('health.no_backup'));
|
||||
$checks[] = self::check('warning', 'continuity', t('health.last_backup'), t('health.no_backup'));
|
||||
} else {
|
||||
$latest = $backups[0];
|
||||
$date = DateTimeImmutable::createFromFormat(
|
||||
|
|
|
|||
Loading…
Reference in a new issue