Files
2026-07-24 14:59:44 +01:00

31 lines
1.1 KiB
PHP

<?php
namespace Modules\Marketplace\Services;
use Illuminate\Support\Facades\App;
final class CompatibilityChecker
{
public function __construct(private VersionConstraint $constraints = new VersionConstraint) {}
public function check(array $manifest): array
{
$errors = [];
$php = (string) ($manifest['php'] ?? '*');
$laravel = (string) ($manifest['laravel'] ?? '*');
$platform = (string) ($manifest['content_manager'] ?? '*');
$platformVersion = (string) config('app.version', '1.0.0');
if (! $this->constraints->matches(PHP_VERSION, $php)) {
$errors[] = "Requires PHP $php; running ".PHP_VERSION.'.';
}
if (! $this->constraints->matches(App::version(), $laravel)) {
$errors[] = "Requires Laravel $laravel; running ".App::version().'.';
}
if (! $this->constraints->matches($platformVersion, $platform)) {
$errors[] = "Requires Content Manager $platform; running $platformVersion.";
}
return ['compatible' => $errors === [], 'errors' => $errors];
}
}