SrtParser\srtFile::saveStats PHP Method

saveStats() public method

Saves statistics as XML file
public saveStats ( string $filename, $output = 'html' )
$filename string
    public function saveStats($filename, $output = 'html')
    {
        if ($output == 'xml') {
            $tmp = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
            $tmp .= '<statistics file="' . $this->filename . '">' . "\n";
            $tmp .= '<range name="tooSlow" color="#9999FF" value="' . $this->stats['tooSlow'] . '" percent="' . $this->getPercent($this->stats['tooSlow']) . '" />' . "\n";
            $tmp .= '<range name="slowAcceptable" color="#99CCFF" value="' . $this->stats['slowAcceptable'] . '" percent="' . $this->getPercent($this->stats['slowAcceptable']) . '" />' . "\n";
            $tmp .= '<range name="aBitSlow" color="#99FFFF" value="' . $this->stats['aBitSlow'] . '" percent="' . $this->getPercent($this->stats['aBitSlow']) . '" />' . "\n";
            $tmp .= '<range name="goodSlow" color="#99FFCC" value="' . $this->stats['goodSlow'] . '" percent="' . $this->getPercent($this->stats['goodSlow']) . '" />' . "\n";
            $tmp .= '<range name="perfect" color="#99FF99" value="' . $this->stats['perfect'] . '" percent="' . $this->getPercent($this->stats['perfect']) . '" />' . "\n";
            $tmp .= '<range name="goodFast" color="#CCFF99" value="' . $this->stats['goodFast'] . '" percent="' . $this->getPercent($this->stats['goodFast']) . '" />' . "\n";
            $tmp .= '<range name="aBitFast" color="#FFFF99" value="' . $this->stats['aBitFast'] . '" percent="' . $this->getPercent($this->stats['aBitFast']) . '" />' . "\n";
            $tmp .= '<range name="fastAcceptable" color="#FFCC99" value="' . $this->stats['fastAcceptable'] . '" percent="' . $this->getPercent($this->stats['fastAcceptable']) . '" />' . "\n";
            $tmp .= '<range name="tooFast" color="#FF9999" value="' . $this->stats['tooFast'] . '" percent="' . $this->getPercent($this->stats['tooFast']) . '" />' . "\n";
            $tmp .= '</statistics>';
        } elseif ($output == 'html') {
            $tmp = '<ul class="srt_stats">';
            $tmp .= '<li style="background-color:#9999FF">TOO SLOW = <span style="float:right;">' . $this->stats['tooSlow'] . ' (' . $this->getPercent($this->stats['tooSlow']) . '%)</span></li>';
            $tmp .= '<li style="background-color:#99CCFF">Slow, acceptable = <span style="float:right;">' . $this->stats['slowAcceptable'] . ' (' . $this->getPercent($this->stats['slowAcceptable']) . '%)</span></li>';
            $tmp .= '<li style="background-color:#99FFFF">A bit slow = <span style="float:right;">' . $this->stats['aBitSlow'] . ' (' . $this->getPercent($this->stats['aBitSlow']) . '%)</span></li>';
            $tmp .= '<li style="background-color:#99FFCC">Good = <span style="float:right;">' . $this->stats['goodSlow'] . ' (' . $this->getPercent($this->stats['goodSlow']) . '%)</span></li>';
            $tmp .= '<li style="background-color:#99FF99">Perfect = <span style="float:right;">' . $this->stats['perfect'] . ' (' . $this->getPercent($this->stats['perfect']) . '%)</span></li>';
            $tmp .= '<li style="background-color:#CCFF99">Good = <span style="float:right;">' . $this->stats['goodFast'] . ' (' . $this->getPercent($this->stats['goodFast']) . '%)</span></li>';
            $tmp .= '<li style="background-color:#FFFF99">A bit fast = <span style="float:right;">' . $this->stats['aBitFast'] . ' (' . $this->getPercent($this->stats['aBitFast']) . '%)</span></li>';
            $tmp .= '<li style="background-color:#FFCC99">Fast, acceptable = <span style="float:right;">' . $this->stats['fastAcceptable'] . ' (' . $this->getPercent($this->stats['fastAcceptable']) . '%)</span></li>';
            $tmp .= '<li style="background-color:#FF9999">TOO FAST = <span style="float:right;">' . $this->stats['tooFast'] . ' (' . $this->getPercent($this->stats['tooFast']) . '%)</span></li>';
            $tmp .= '</ul>';
        }
        file_put_contents($filename, $tmp);
    }