Last active
July 8, 2016 10:57
-
-
Save TorbenKoehn/9ada8d17d615ce6b40bbaa7228cf4194 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Request | |
{ | |
//... | |
public function __cast($type) { | |
switch ($type) { | |
case Response::class: | |
$headers = []; | |
//Create fitting headers based on request headers, e.g languages, content-type, compression, caching etc. | |
return new Response(200, $headers); | |
case 'array': | |
return ['uri' => $this->uri, 'headers' => $this->headers, 'body' => $this->body]; | |
} | |
} | |
} | |
$response = (Response)$request; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment