Cachearium\CacheData::stringify PHP Method

stringify() public method

Converts this data to a string that can output. This is not a hash key or a serialization, but an actual render for humans.
public stringify ( CacheAbstract $c, $recurse = true )
$c CacheAbstract
    public function stringify(CacheAbstract $c, $recurse = true)
    {
        $retval = [];
        foreach ($this->data as $item) {
            if ($item['type'] == self::CACHEDATA_TYPE_CALLBACK) {
                $callback = $item['data'];
                if (is_callable($callback)) {
                    $retval[] = call_user_func($callback);
                } else {
                    // throw?
                }
            } else {
                if ($item['type'] == self::CACHEDATA_TYPE_RECURSION) {
                    if ($recurse) {
                        $retval[] = $c->get($item['data']);
                    }
                } else {
                    if ($item['type'] == self::CACHEDATA_TYPE_RECURSION_DATA) {
                        if ($recurse) {
                            $data = $c->getData($item['data']);
                            $retval[] = $data->stringify($c);
                        }
                    } else {
                        $retval[] = $item['data'];
                    }
                }
            }
        }
        return implode('', $retval);
    }