public function formatStats($stats, $debug = false)
    {
        if (!is_array($stats)) {
            return "No statistics returned.\n";
        }

        if (count($stats) == 0) {
            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";
            }

            if ($debug) {
                $out .= "\n";
                foreach ($item as $key => $value) {
                    $out .= "\t" . $key . ': ' . $value . "\n";
                }
            }
        }

        return $out;
    }
public function formatStats($stats, $debug = false)
    {
        if (!is_array($stats)) {
            return "No statistics returned.\n";
        }

        if (count($stats) == 0) {
            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";
            }

            if ($debug) {
                $out .= "\n";
                foreach ($item as $key => $value) {
                    $out .= "\t" . $key . ': ' . $value . "\n";
                }
            }
        }

        return $out;
    }
public function formatStats ( $ stats , $ debug = false ) { if ( ! is_array ( $ stats ) ) { return "No statistics returned.\n" ; } if ( count ( $ stats ) == 0 ) { 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" ; } if ( $ debug ) { $ out .= "\n" ; foreach ( $ item as $ key => $ value ) { $ out .= "\t" . $ key . ': ' . $ value . "\n" ; } } } return $ out ; }
Format the raw array for the command line report

@param array $stats An array of memcache::extendedstats
@param bool $debug (default: false) True causes a raw dump of the stats array to be provided
@return string ConsoleComponent-formatted output, suitable for ->writeln() usage
Format the raw array for the command line report