PATH:
home
/
lab2454c
/
internationalminersbank.com
/
backup
/
vendor
/
facade
/
ignition
/
src
/
SolutionProviders
<?php namespace Facade\Ignition\SolutionProviders; use BadMethodCallException; use Facade\IgnitionContracts\BaseSolution; use Facade\IgnitionContracts\HasSolutionsForThrowable; use Illuminate\Support\Collection; use ReflectionClass; use ReflectionMethod; use Throwable; class BadMethodCallSolutionProvider implements HasSolutionsForThrowable { protected const REGEX = '/([a-zA-Z\\\\]+)::([a-zA-Z]+)/m'; public function canSolve(Throwable $throwable): bool { if (! $throwable instanceof BadMethodCallException) { return false; } if (is_null($this->getClassAndMethodFromExceptionMessage($throwable->getMessage()))) { return false; } return true; } public function getSolutions(Throwable $throwable): array { return [ BaseSolution::create('Bad Method Call') ->setSolutionDescription($this->getSolutionDescription($throwable)), ]; } public function getSolutionDescription(Throwable $throwable): string { if (! $this->canSolve($throwable)) { return ''; } extract($this->getClassAndMethodFromExceptionMessage($throwable->getMessage()), EXTR_OVERWRITE); $possibleMethod = $this->findPossibleMethod($class, $method); return "Did you mean {$class}::{$possibleMethod->name}() ?"; } protected function getClassAndMethodFromExceptionMessage(string $message): ?array { if (! preg_match(self::REGEX, $message, $matches)) { return null; } return [ 'class' => $matches[1], 'method' => $matches[2], ]; } protected function findPossibleMethod(string $class, string $invalidMethodName) { return $this->getAvailableMethods($class) ->sortByDesc(function (ReflectionMethod $method) use ($invalidMethodName) { similar_text($invalidMethodName, $method->name, $percentage); return $percentage; })->first(); } protected function getAvailableMethods($class): Collection { $class = new ReflectionClass($class); return Collection::make($class->getMethods()); } }
[-] UndefinedVariableSolutionProvider.php
[edit]
[-] UndefinedPropertySolutionProvider.php
[edit]
[-] UndefinedLivewirePropertySolutionProvider.php
[edit]
[-] MissingImportSolutionProvider.php
[edit]
[-] ViewNotFoundSolutionProvider.php
[edit]
[+]
..
[-] MissingAppKeySolutionProvider.php
[edit]
[-] SolutionProviderRepository.php
[edit]
[-] DefaultDbNameSolutionProvider.php
[edit]
[-] UndefinedLivewireMethodSolutionProvider.php
[edit]
[-] IncorrectValetDbCredentialsSolutionProvider.php
[edit]
[-] MissingPackageSolutionProvider.php
[edit]
[-] MergeConflictSolutionProvider.php
[edit]
[-] TableNotFoundSolutionProvider.php
[edit]
[-] MissingColumnSolutionProvider.php
[edit]
[-] MissingMixManifestSolutionProvider.php
[edit]
[-] RunningLaravelDuskInProductionProvider.php
[edit]
[-] RouteNotDefinedSolutionProvider.php
[edit]
[-] MissingLivewireComponentSolutionProvider.php
[edit]
[-] UnknownValidationSolutionProvider.php
[edit]
[-] LazyLoadingViolationSolutionProvider.php
[edit]
[-] BadMethodCallSolutionProvider.php
[edit]
[-] InvalidRouteActionSolutionProvider.php
[edit]