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 Livewire\Features\SupportMultipleRootElementDetection; use Livewire\Comp..
Decoded Output download
<?php
namespace Livewire\Features\SupportMultipleRootElementDetection;
use Livewire\ComponentHook;
use function Livewire\on;
class SupportMultipleRootElementDetection extends ComponentHook
{
static function provide() {
on('mount', function ($component) {
if (! config('app.debug')) return;
return function ($html) use ($component) {
(new static)->warnAgainstMoreThanOneRootElement($component, $html);
};
});
}
function warnAgainstMoreThanOneRootElement($component, $html)
{
$count = $this->getRootElementCount($html);
if ($count > 1) {
throw new MultipleRootElementsDetectedException($component);
}
}
function getRootElementCount($html)
{
$dom = new \DOMDocument();
@$dom->loadHTML($html);
$body = $dom->getElementsByTagName('body')->item(0);
$count = 0;
foreach ($body->childNodes as $child) {
if ($child->nodeType == XML_ELEMENT_NODE) {
if ($child->tagName === 'script') continue;
$count++;
}
}
return $count;
}
}
?>
Did this file decode correctly?
Original Code
<?php
namespace Livewire\Features\SupportMultipleRootElementDetection;
use Livewire\ComponentHook;
use function Livewire\on;
class SupportMultipleRootElementDetection extends ComponentHook
{
static function provide() {
on('mount', function ($component) {
if (! config('app.debug')) return;
return function ($html) use ($component) {
(new static)->warnAgainstMoreThanOneRootElement($component, $html);
};
});
}
function warnAgainstMoreThanOneRootElement($component, $html)
{
$count = $this->getRootElementCount($html);
if ($count > 1) {
throw new MultipleRootElementsDetectedException($component);
}
}
function getRootElementCount($html)
{
$dom = new \DOMDocument();
@$dom->loadHTML($html);
$body = $dom->getElementsByTagName('body')->item(0);
$count = 0;
foreach ($body->childNodes as $child) {
if ($child->nodeType == XML_ELEMENT_NODE) {
if ($child->tagName === 'script') continue;
$count++;
}
}
return $count;
}
}
Function Calls
None |
Stats
MD5 | 66e86a36c76f95adefbb0ea5e681014a |
Eval Count | 0 |
Decode Time | 108 ms |