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 /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@..

Decoded Output download

<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <[email protected]>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Bundle\WebProfilerBundle\Profiler;

use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\Profiler\Profile;
use Symfony\Component\HttpKernel\Profiler\Profiler;
use Twig\Environment;

/**
 * @author Fabien Potencier <[email protected]>
 * @author Artur Wielogrski <[email protected]>
 *
 * @internal
 */
class TemplateManager
{
    public function __construct(
        protected Profiler $profiler,
        protected Environment $twig,
        protected array $templates,
    ) {
    }

    /**
     * Gets the template name for a given panel.
     *
     * @throws NotFoundHttpException
     */
    public function getName(Profile $profile, string $panel): mixed
    {
        $templates = $this->getNames($profile);

        if (!isset($templates[$panel])) {
            throw new NotFoundHttpException(sprintf('Panel "%s" is not registered in profiler or is not present in viewed profile.', $panel));
        }

        return $templates[$panel];
    }

    /**
     * Gets template names of templates that are present in the viewed profile.
     *
     * @throws \UnexpectedValueException
     */
    public function getNames(Profile $profile): array
    {
        $loader = $this->twig->getLoader();
        $templates = [];

        foreach ($this->templates as $arguments) {
            if (null === $arguments) {
                continue;
            }

            [$name, $template] = $arguments;

            if (!$this->profiler->has($name) || !$profile->hasCollector($name)) {
                continue;
            }

            if (str_ends_with($template, '.html.twig')) {
                $template = substr($template, 0, -10);
            }

            if (!$loader->exists($template.'.html.twig')) {
                throw new \UnexpectedValueException(sprintf('The profiler template "%s.html.twig" for data collector "%s" does not exist.', $template, $name));
            }

            $templates[$name] = $template.'.html.twig';
        }

        return $templates;
    }
}
 ?>

Did this file decode correctly?

Original Code

<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <[email protected]>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Bundle\WebProfilerBundle\Profiler;

use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\Profiler\Profile;
use Symfony\Component\HttpKernel\Profiler\Profiler;
use Twig\Environment;

/**
 * @author Fabien Potencier <[email protected]>
 * @author Artur Wielogrski <[email protected]>
 *
 * @internal
 */
class TemplateManager
{
    public function __construct(
        protected Profiler $profiler,
        protected Environment $twig,
        protected array $templates,
    ) {
    }

    /**
     * Gets the template name for a given panel.
     *
     * @throws NotFoundHttpException
     */
    public function getName(Profile $profile, string $panel): mixed
    {
        $templates = $this->getNames($profile);

        if (!isset($templates[$panel])) {
            throw new NotFoundHttpException(sprintf('Panel "%s" is not registered in profiler or is not present in viewed profile.', $panel));
        }

        return $templates[$panel];
    }

    /**
     * Gets template names of templates that are present in the viewed profile.
     *
     * @throws \UnexpectedValueException
     */
    public function getNames(Profile $profile): array
    {
        $loader = $this->twig->getLoader();
        $templates = [];

        foreach ($this->templates as $arguments) {
            if (null === $arguments) {
                continue;
            }

            [$name, $template] = $arguments;

            if (!$this->profiler->has($name) || !$profile->hasCollector($name)) {
                continue;
            }

            if (str_ends_with($template, '.html.twig')) {
                $template = substr($template, 0, -10);
            }

            if (!$loader->exists($template.'.html.twig')) {
                throw new \UnexpectedValueException(sprintf('The profiler template "%s.html.twig" for data collector "%s" does not exist.', $template, $name));
            }

            $templates[$name] = $template.'.html.twig';
        }

        return $templates;
    }
}

Function Calls

None

Variables

None

Stats

MD5 cae2281917ee2ba2f91bb3b04984e0c3
Eval Count 0
Decode Time 145 ms