| Server IP : 68.178.172.28 / Your IP : 216.73.216.32 Web Server : Apache System : Linux 28.172.178.68.host.secureserver.net 4.18.0-553.89.1.el8_10.x86_64 #1 SMP Mon Dec 8 03:53:08 EST 2025 x86_64 User : kiskarnal ( 1003) PHP Version : 8.0.30 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/kiskarnal/www/vendor/facade/ignition/src/SolutionProviders/ |
Upload File : |
<?php
namespace Facade\Ignition\SolutionProviders;
use Facade\Ignition\Solutions\MissingPackageSolution;
use Facade\Ignition\Support\Packagist\Package;
use Facade\Ignition\Support\Packagist\Packagist;
use Facade\IgnitionContracts\HasSolutionsForThrowable;
use Illuminate\Support\Str;
use Throwable;
class MissingPackageSolutionProvider implements HasSolutionsForThrowable
{
/** @var \Facade\Ignition\Support\Packagist\Package|null */
protected $package;
public function canSolve(Throwable $throwable): bool
{
$pattern = '/Class \'([^\s]+)\' not found/m';
if (! preg_match($pattern, $throwable->getMessage(), $matches)) {
return false;
}
$class = $matches[1];
if (Str::startsWith($class, app()->getNamespace())) {
return false;
}
$this->package = $this->findPackageFromClassName($class);
return ! is_null($this->package);
}
public function getSolutions(Throwable $throwable): array
{
return [new MissingPackageSolution($this->package)];
}
protected function findPackageFromClassName(string $missingClassName): ?Package
{
if (! $package = $this->findComposerPackageForClassName($missingClassName)) {
return null;
}
return $package->hasNamespaceThatContainsClassName($missingClassName)
? $package
: null;
}
protected function findComposerPackageForClassName(string $className): ?Package
{
$packages = Packagist::findPackagesForClassName($className);
return $packages[0] ?? null;
}
}