111e83be864cecff292ac9b0587a41fda8d48267
[yaffs-website] / vendor / zendframework / zend-diactoros / src / Response / SapiEmitter.php
1 <?php
2 /**
3  * @see       https://github.com/zendframework/zend-diactoros for the canonical source repository
4  * @copyright Copyright (c) 2015-2017 Zend Technologies USA Inc. (http://www.zend.com)
5  * @license   https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md New BSD License
6  */
7
8 namespace Zend\Diactoros\Response;
9
10 use Psr\Http\Message\ResponseInterface;
11 use RuntimeException;
12
13 class SapiEmitter implements EmitterInterface
14 {
15     use SapiEmitterTrait;
16
17     /**
18      * Emits a response for a PHP SAPI environment.
19      *
20      * Emits the status line and headers via the header() function, and the
21      * body content via the output buffer.
22      *
23      * @param ResponseInterface $response
24      */
25     public function emit(ResponseInterface $response)
26     {
27         $this->assertNoPreviousOutput();
28
29         $this->emitHeaders($response);
30         $this->emitStatusLine($response);
31         $this->emitBody($response);
32     }
33
34     /**
35      * Emit the message body.
36      *
37      * @param ResponseInterface $response
38      */
39     private function emitBody(ResponseInterface $response)
40     {
41         echo $response->getBody();
42     }
43 }