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 BookStack\Util; class SvgIcon { public function __construct( ..

Decoded Output download

<?php

namespace BookStack\Util;

class SvgIcon
{
    public function __construct(
        protected string $name,
        protected array $attrs = []
    ) {
    }

    public function toHtml(): string
    {
        $attrs = array_merge([
            'class'     => 'svg-icon',
            'data-icon' => $this->name,
            'role'      => 'presentation',
        ], $this->attrs);

        $attrString = ' ';
        foreach ($attrs as $attrName => $attr) {
            $attrString .= $attrName . '="' . $attr . '" ';
        }

        $iconPath = resource_path('icons/' . $this->name . '.svg');
        $themeIconPath = theme_path('icons/' . $this->name . '.svg');

        if ($themeIconPath && file_exists($themeIconPath)) {
            $iconPath = $themeIconPath;
        } elseif (!file_exists($iconPath)) {
            return '';
        }

        $fileContents = file_get_contents($iconPath);

        return str_replace('<svg', '<svg' . $attrString, $fileContents);
    }
}
 ?>

Did this file decode correctly?

Original Code

<?php

namespace BookStack\Util;

class SvgIcon
{
    public function __construct(
        protected string $name,
        protected array $attrs = []
    ) {
    }

    public function toHtml(): string
    {
        $attrs = array_merge([
            'class'     => 'svg-icon',
            'data-icon' => $this->name,
            'role'      => 'presentation',
        ], $this->attrs);

        $attrString = ' ';
        foreach ($attrs as $attrName => $attr) {
            $attrString .= $attrName . '="' . $attr . '" ';
        }

        $iconPath = resource_path('icons/' . $this->name . '.svg');
        $themeIconPath = theme_path('icons/' . $this->name . '.svg');

        if ($themeIconPath && file_exists($themeIconPath)) {
            $iconPath = $themeIconPath;
        } elseif (!file_exists($iconPath)) {
            return '';
        }

        $fileContents = file_get_contents($iconPath);

        return str_replace('<svg', '<svg' . $attrString, $fileContents);
    }
}

Function Calls

None

Variables

None

Stats

MD5 537dd6235279d1e07253fc5715a9371e
Eval Count 0
Decode Time 90 ms