ICanBoogie/ICanBoogie master
  • Namespace
  • Class

Namespaces

  • ICanBoogie
    • Autoconfig
    • Binding
    • Core
    • Routing
    • Session

Classes

  • PingController
 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 
<?php

namespace ICanBoogie\Routing;

use ICanBoogie\Binding\PrototypedBindings;
use ICanBoogie\HTTP\Request;

class PingController extends Controller
{
    use PrototypedBindings;

    /**
     * @param float $finish
     *
     * @return string
     */
    static private function format_time($finish)
    {
        return number_format(($finish - $_SERVER['REQUEST_TIME_FLOAT']) * 1000, 3, '.', '') . ' ms';
    }

    /**
     * @inheritdoc
     */
    protected function action(Request $request)
    {
        $this->response->content_type = 'text/plain';
        $session = $this->app->session;

        // @codeCoverageIgnoreStart
        if ($session->is_referenced)
        {
            $session->start_or_reuse();
        }
        // @codeCoverageIgnoreEnd

        $rc = 'pong';

        if ($this->request['timer'] !== null)
        {
            $boot_time = self::format_time($_SERVER['ICANBOOGIE_READY_TIME_FLOAT']);
            $run_time = self::format_time(microtime(true));

            $rc .= ", in $run_time (ready in $boot_time)";
        }

        return $rc;
    }
}
ICanBoogie/ICanBoogie master API documentation generated by ApiGen