designcise/bitframe

View on GitHub
src/Emitter/SapiEmitter.php

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
<?php

/**
 * BitFrame Framework (https://www.bitframephp.com)
 *
 * @author    Daniyal Hamid
 * @copyright Copyright (c) 2017-2023 Daniyal Hamid (https://designcise.com)
 * @license   https://bitframephp.com/about/license MIT License
 */

declare(strict_types=1);

namespace BitFrame\Emitter;

use Psr\Http\Message\ResponseInterface;

use function headers_sent;

/**
 * Simple sapi emitter.
 */
class SapiEmitter extends AbstractSapiEmitter
{
    public function emit(ResponseInterface $response): void
    {
        if (! headers_sent()) {
            $this->emitHeaders($response);
        }

        echo $response->getBody();
    }
}