This repository has been archived on 2018-10-11. You can view files and clone it, but cannot push or open issues or pull requests.
sleepy/Sleepy/Type/HTML.php

57 lines
961 B
PHP
Raw Normal View History

2014-05-07 14:05:13 -04:00
<?php
/**
* Sleepy - a REST framework
*
*
* A PHP Rest Framework valuing convention over configuration,
* but aiming to be as flexible as possible
*
* @author Timothy J. Warren
*/
namespace Sleepy\Type;
2014-05-14 10:32:31 -04:00
use \Sleepy\Core\Abstracts\Type as aType;
2014-05-07 14:05:13 -04:00
/**
* Class for HTML output
*/
class HTML extends aType {
/**
* The mime type for output
*
* @var string
*/
protected $mime = 'text/html';
/**
* Convert the data into the output format
*
* @param mixed $data
* @return string
*/
public function serialize($data = NULL)
{
2014-05-14 10:32:31 -04:00
$this->set_data($data);
2014-05-07 14:05:13 -04:00
if (is_string($data)) return $data;
// Lets use JSON as an output format if the value isn't scalar
return '<pre>' . json_encode($data, JSON_PRETTY_PRINT) . '</pre>';
}
/**
* Convert the encoded data to a native format
*
* @param string $data_string
* @return object
*/
public function unserialize($data_string)
{
return NULL;
}
}
// End of types/JSON.php