Source of file ResponseTrait.php
Size: 0,929 Bytes - Last Modified: 2017-11-08T13:54:24+00:00
/home/travis/build/bluzphp/framework/src/Response/ResponseTrait.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 | <?php /** * Bluz Framework Component * * @copyright Bluz PHP Team * @link https://github.com/bluzphp/framework */ declare(strict_types=1); namespace Bluz\Response; /** * Response Trait * * @package Bluz\Response * @author Anton Shevchuk */ trait ResponseTrait { /** * @return string */ abstract public function jsonSerialize(); /** * @return string */ abstract public function __toString(); /** * Render object as HTML or JSON * * @param string $type * * @return string */ public function render($type = 'HTML') { // switch statement by response type switch (strtoupper($type)) { case 'CLI': case 'JSON': return $this->jsonSerialize(); case 'HTML': return $this->__toString(); default: return ''; } } } |