Lsrur\Inspector\Collectors\MessageCollector::getScript PHP Method

getScript() public method

public getScript ( ) : string
return string
    public function getScript()
    {
        $script = "console.group('MESSAGES');";
        $groupCount = 0;
        foreach ($this->stack as $item) {
            $name = isset($item['name']) ? $item['name'] : null;
            if (isset($item['trace'])) {
                $name .= ' (' . $item['trace'] . ')';
            }
            $name = trim($name);
            if (in_array($item['style'], ['info', 'log', 'error', 'warning', 'success'])) {
                $script .= $this->cl($item['style'], $name, $item['value']);
            } elseif ($item['style'] == 'table') {
                $script .= $this->clGroup($name);
                $script .= $this->clTable($item['value']);
                $script .= $this->clGroupEnd();
            } elseif ($item['style'] == 'group') {
                $script .= $this->clGroup($name . ' (' . $item['time'] . 'ms)');
                $groupCount++;
            } elseif ($item['style'] == 'groupend') {
                $script .= $this->clGroupEnd();
                $groupCount--;
            }
        }
        // Close forgotten groups
        for ($i = 0; $i < $groupCount; $i++) {
            $script .= $this->clGroupEnd();
        }
        $script .= 'console.groupEnd();';
        return $script;
    }