lithium\util\Collection::_to PHP Method

_to() protected method

protected _to ( $format, &$data, &$options )
    protected function _to($format, &$data, &$options)
    {
        if (is_object($format) && is_callable($format)) {
            return $format($data, $options);
        }
        if (isset(static::$_formats[$format]) && is_callable(static::$_formats[$format])) {
            $handler = static::$_formats[$format];
            $handler = is_string($handler) ? explode('::', $handler, 2) : $handler;
            if (is_array($handler)) {
                list($class, $method) = $handler;
                return $class::$method($data, $options);
            }
            return $handler($data, $options);
        }
        foreach (static::$_formats as $key => $handler) {
            if (!is_int($key)) {
                continue;
            }
            if (in_array($format, $handler::formats($format, $data, $options))) {
                return $handler::to($format, $data, $options);
            }
        }
    }