src/CSPBuilder.php
public function injectCSPHeader(MessageInterface $message, bool $legacy = false): MessageInterface
    {
        if ($this->needsCompile) {
            $this->compile();
        }
        foreach ($this->getRequireHeaders() as $header) {
            list ($key, $value) = $header;
            $message = $message->withAddedHeader($key, $value);
        }
        foreach ($this->getHeaderKeys($legacy) as $key) {
            $message = $message->withAddedHeader($key, $this->compiled);
        }
        return $message;
    }
public function injectCSPHeader(MessageInterface $message, bool $legacy = false): MessageInterface
    {
        if ($this->needsCompile) {
            $this->compile();
        }
        foreach ($this->getRequireHeaders() as $header) {
            list ($key, $value) = $header;
            $message = $message->withAddedHeader($key, $value);
        }
        foreach ($this->getHeaderKeys($legacy) as $key) {
            $message = $message->withAddedHeader($key, $this->compiled);
        }
        return $message;
    }
public function injectCSPHeader ( MessageInterface $ message , bool $ legacy = false ) : MessageInterface { if ( $ this -> needsCompile ) { $ this -> compile ( ) ; } foreach ( $ this -> getRequireHeaders ( ) as $ header ) { list ( $ key , $ value ) = $ header ; $ message = $ message -> withAddedHeader ( $ key , $ value ) ; } foreach ( $ this -> getHeaderKeys ( $ legacy ) as $ key ) { $ message = $ message -> withAddedHeader ( $ key , $ this -> compiled ) ; } return $ message ; }
PSR-7 header injection.

This will inject the header into your PSR-7 object. (Request, Response,
etc.) This method returns an instance of whatever you passed, so long
as it implements MessageInterface.

@param \Psr\Http\Message\MessageInterface $message
@param bool $legacy
@return \Psr\Http\Message\MessageInterface
PSR - 7 header injection .