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

getScript() public method

public getScript ( )
    public function getScript()
    {
        if (count($this->timers) == 0) {
            return "";
        }
        $script = "console.groupCollapsed('TIMERS (" . count($this->timers) . ")');";
        foreach ($this->timers as $key => $value) {
            $style = $value['type'] == 'timer' ? 'font-size:11px;line-height:1.8em;border-radius:3px;padding:3px 5px;color:white; background-color: #18BC9C' : 'font-size:11px;line-height:1.8em;border-radius:3px;padding:3px 5px;color:white; background-color: #3498DB';
            if ($value['time'] > 0) {
                $script .= "console.log('{$key}: {$value['time']}ms %c{$value['type']}','{$style}');";
            } else {
                $script .= $this->cl('log', $key, 'unfinished');
            }
        }
        $script .= 'console.groupEnd();';
        return $script;
    }