Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php namespace PowerComponents\LivewirePowerGrid\Actions; use function Laravel\Prompts\..

Decoded Output download

<?php

namespace PowerComponents\LivewirePowerGrid\Actions;

use function Laravel\Prompts\{error, suggest};

final class AskModelName
{
    protected static string $model = '';

    protected static string $fqn = '';

    /**
     * @return array{model: string, fqn: string}
     */
    public static function handle(): array
    {
        {
            while (self::$model === '') {
                self::setModel(suggest(
                    label: 'Select a Model or enter its Fully qualified name.',
                    options: ListModels::handle(),
                    required: true,
                ));
            }

            return ['model' => self::$model, 'fqn' => self::$fqn];
        }
    }

    private static function setModel(string $model): void
    {
        self::$model = str($model)->replaceMatches('#[^A-Za-z0-9\\]#', '')->toString();

        self::parseFqn();

        self::checkIfModelExists();
    }

    private static function parseFqn(): void
    {
        self::$fqn = 'App\Models\' . self::$model;

        if (str_contains(self::$model, '\')) {
            self::$fqn   = self::$model;
            self::$model = str(self::$fqn)->rtrim('\')->afterLast('\');
        }
    }

    private static function checkIfModelExists(): void
    {
        if (!class_exists(self::$fqn)) {
            error("Cannot find class [" . self::$fqn . "]. Try again or press Ctrl+C to abort.");

            self::$model = '';

            self::$fqn = '';
        }
    }
}
 ?>

Did this file decode correctly?

Original Code

<?php

namespace PowerComponents\LivewirePowerGrid\Actions;

use function Laravel\Prompts\{error, suggest};

final class AskModelName
{
    protected static string $model = '';

    protected static string $fqn = '';

    /**
     * @return array{model: string, fqn: string}
     */
    public static function handle(): array
    {
        {
            while (self::$model === '') {
                self::setModel(suggest(
                    label: 'Select a Model or enter its Fully qualified name.',
                    options: ListModels::handle(),
                    required: true,
                ));
            }

            return ['model' => self::$model, 'fqn' => self::$fqn];
        }
    }

    private static function setModel(string $model): void
    {
        self::$model = str($model)->replaceMatches('#[^A-Za-z0-9\\\\]#', '')->toString();

        self::parseFqn();

        self::checkIfModelExists();
    }

    private static function parseFqn(): void
    {
        self::$fqn = 'App\\Models\\' . self::$model;

        if (str_contains(self::$model, '\\')) {
            self::$fqn   = self::$model;
            self::$model = str(self::$fqn)->rtrim('\\')->afterLast('\\');
        }
    }

    private static function checkIfModelExists(): void
    {
        if (!class_exists(self::$fqn)) {
            error("Cannot find class [" . self::$fqn . "]. Try again or press Ctrl+C to abort.");

            self::$model = '';

            self::$fqn = '';
        }
    }
}

Function Calls

None

Variables

None

Stats

MD5 eb3af9ff0302f73cf0728468603eed68
Eval Count 0
Decode Time 94 ms