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 WireUi\View; use Illuminate\Support\Arr; use Illuminate\Support\Str; use..
Decoded Output download
<?php
namespace WireUi\View;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use WireUi\Facades\WireUi;
use WireUi\Support\{ComponentPack};
trait ManageAttributes
{
public ?string $config = null;
private array $setVariables = [];
private array $smartAttributes = [];
private const METHODS = [
'setupSize',
'setupProps',
'setupButton',
'setupRounded',
'setupSpinner',
'setupVariant',
'setupColor',
'setupStateColor',
];
private function setConfig(): void
{
$this->config = WireUi::components()->resolveByAlias($this->componentName);
}
private function runWireUiComponent(array $data): array
{
$this->setConfig();
$this->call('mounted', $data);
foreach (self::METHODS as $method) {
$this->call($method, $data);
}
$this->call('processed', $data);
foreach ($this->setVariables as $attribute) {
$data[$attribute] = $this->{$attribute};
}
$data['attributes'] = $this->attributes->except($this->smartAttributes);
return tap($data, fn (array &$data) => $this->call('finished', $data));
}
private function call(string $function, array &$data): void
{
if (method_exists($this, $function)) {
$this->{$function}($data);
}
}
protected function getData(string $attribute, mixed $default = null): mixed
{
if ($this->attributes->has($kebab = Str::kebab($attribute))) {
$this->smartAttributes($kebab);
return $this->attributes->get($kebab);
}
if ($this->attributes->has($camel = Str::camel($attribute))) {
$this->smartAttributes($camel);
return $this->attributes->get($camel);
}
if ($kebab === 'icon-size' && property_exists($this, 'size')) {
return $this->size;
}
return config("wireui.{$this->config}.default.{$kebab}") ?? $default;
}
protected function getDataModifier(string $attribute, ComponentPack $dataPack): mixed
{
$value = $this->attributes->get($attribute) ?? $this->getMatchModifier($dataPack->keys());
$remove = in_array($value, $dataPack->keys()) ? [$value] : [];
$this->smartAttributes([$attribute, ...$remove]);
return $value ?? config("wireui.{$this->config}.default.{$attribute}");
}
protected function setVariables(mixed $variables): void
{
collect(Arr::wrap($variables))->filter()->each(
fn ($value) => $this->setVariables[] = $value,
);
}
protected function smartAttributes(mixed $attributes): void
{
collect(Arr::wrap($attributes))->filter()->each(
fn ($value) => $this->smartAttributes[] = $value,
);
}
protected function getMatchModifier(array $keys): ?string
{
return array_key_first($this->attributes->only($keys)->getAttributes());
}
protected function useValidation(): bool
{
return rescue(fn () => $this->useValidationColors, false, false);
}
}
?>
Did this file decode correctly?
Original Code
<?php
namespace WireUi\View;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use WireUi\Facades\WireUi;
use WireUi\Support\{ComponentPack};
trait ManageAttributes
{
public ?string $config = null;
private array $setVariables = [];
private array $smartAttributes = [];
private const METHODS = [
'setupSize',
'setupProps',
'setupButton',
'setupRounded',
'setupSpinner',
'setupVariant',
'setupColor',
'setupStateColor',
];
private function setConfig(): void
{
$this->config = WireUi::components()->resolveByAlias($this->componentName);
}
private function runWireUiComponent(array $data): array
{
$this->setConfig();
$this->call('mounted', $data);
foreach (self::METHODS as $method) {
$this->call($method, $data);
}
$this->call('processed', $data);
foreach ($this->setVariables as $attribute) {
$data[$attribute] = $this->{$attribute};
}
$data['attributes'] = $this->attributes->except($this->smartAttributes);
return tap($data, fn (array &$data) => $this->call('finished', $data));
}
private function call(string $function, array &$data): void
{
if (method_exists($this, $function)) {
$this->{$function}($data);
}
}
protected function getData(string $attribute, mixed $default = null): mixed
{
if ($this->attributes->has($kebab = Str::kebab($attribute))) {
$this->smartAttributes($kebab);
return $this->attributes->get($kebab);
}
if ($this->attributes->has($camel = Str::camel($attribute))) {
$this->smartAttributes($camel);
return $this->attributes->get($camel);
}
if ($kebab === 'icon-size' && property_exists($this, 'size')) {
return $this->size;
}
return config("wireui.{$this->config}.default.{$kebab}") ?? $default;
}
protected function getDataModifier(string $attribute, ComponentPack $dataPack): mixed
{
$value = $this->attributes->get($attribute) ?? $this->getMatchModifier($dataPack->keys());
$remove = in_array($value, $dataPack->keys()) ? [$value] : [];
$this->smartAttributes([$attribute, ...$remove]);
return $value ?? config("wireui.{$this->config}.default.{$attribute}");
}
protected function setVariables(mixed $variables): void
{
collect(Arr::wrap($variables))->filter()->each(
fn ($value) => $this->setVariables[] = $value,
);
}
protected function smartAttributes(mixed $attributes): void
{
collect(Arr::wrap($attributes))->filter()->each(
fn ($value) => $this->smartAttributes[] = $value,
);
}
protected function getMatchModifier(array $keys): ?string
{
return array_key_first($this->attributes->only($keys)->getAttributes());
}
protected function useValidation(): bool
{
return rescue(fn () => $this->useValidationColors, false, false);
}
}
Function Calls
None |
Stats
MD5 | 5e4b5f8e56bb46f4585560a75404118c |
Eval Count | 0 |
Decode Time | 98 ms |