Command/StatisticsCommand.php
protected function formatStats($stats)
    {
        if (!$stats) {
        return "No statistics returned.\n";
        }

        $out = "Servers found: " . count($stats) . "\n\n";
        foreach ($stats as $host => $item) {
            if (!is_array($item) || count($item) == 0) {
                $out .= "  <error>" . $host . "</error>\n";

                continue;
            }

            $out .= "<info>Host:\t" . $host . "</info>\n";
            $out .= "\tUsage: " . $this->formatUsage($item['bytes'], $item['limit_maxbytes']) . "\n";
            $out .= "\tUptime: " . $this->formatUptime($item['uptime']) . "\n";
            $out .= "\tOpen Connections: " . $item['curr_connections'] . "\n";
            $out .= "\tHits: " . $item['get_hits'] . "\n";
            $out .= "\tMisses: " . $item['get_misses'] . "\n";
            if ($item['get_hits'] + $item['get_misses'] > 0 ) {
                $out .= "\tHelpfulness: " . round($item['get_hits'] / ($item['get_hits'] + $item['get_misses']) * 100, 2) . "%\n";
            }
        }

        return $out;
    }
protected function formatStats($stats)
    {
        if (!$stats) {
        return "No statistics returned.\n";
        }

        $out = "Servers found: " . count($stats) . "\n\n";
        foreach ($stats as $host => $item) {
            if (!is_array($item) || count($item) == 0) {
                $out .= "  <error>" . $host . "</error>\n";

                continue;
            }

            $out .= "<info>Host:\t" . $host . "</info>\n";
            $out .= "\tUsage: " . $this->formatUsage($item['bytes'], $item['limit_maxbytes']) . "\n";
            $out .= "\tUptime: " . $this->formatUptime($item['uptime']) . "\n";
            $out .= "\tOpen Connections: " . $item['curr_connections'] . "\n";
            $out .= "\tHits: " . $item['get_hits'] . "\n";
            $out .= "\tMisses: " . $item['get_misses'] . "\n";
            if ($item['get_hits'] + $item['get_misses'] > 0 ) {
                $out .= "\tHelpfulness: " . round($item['get_hits'] / ($item['get_hits'] + $item['get_misses']) * 100, 2) . "%\n";
            }
        }

        return $out;
    }
protected function formatStats ( $ stats ) { if ( ! $ stats ) { return "No statistics returned.\n" ; } $ out = "Servers found: " . count ( $ stats ) . "\n\n" ; foreach ( $ stats as $ host => $ item ) { if ( ! is_array ( $ item ) || count ( $ item ) == 0 ) { $ out .= "  <error>" . $ host . "</error>\n" ; continue ; } $ out .= "<info>Host:\t" . $ host . "</info>\n" ; $ out .= "\tUsage: " . $ this -> formatUsage ( $ item [ 'bytes' ] , $ item [ 'limit_maxbytes' ] ) . "\n" ; $ out .= "\tUptime: " . $ this -> formatUptime ( $ item [ 'uptime' ] ) . "\n" ; $ out .= "\tOpen Connections: " . $ item [ 'curr_connections' ] . "\n" ; $ out .= "\tHits: " . $ item [ 'get_hits' ] . "\n" ; $ out .= "\tMisses: " . $ item [ 'get_misses' ] . "\n" ; if ( $ item [ 'get_hits' ] + $ item [ 'get_misses' ] > 0 ) { $ out .= "\tHelpfulness: " . round ( $ item [ 'get_hits' ] / ( $ item [ 'get_hits' ] + $ item [ 'get_misses' ] ) * 100 , 2 ) . "%\n" ; } } return $ out ; }
Format the raw array for the command line report

@param array $stats An array of memcache::extendedstats

@return string ConsoleComponent-formatted output, suitable for ->writeln() usage
Format the raw array for the command line report