Bluz\Response\Response::addHeaders PHP Method

addHeaders() public method

Each array key MUST be a string representing the case-insensitive name of a header. Each value MUST be either a string or an array of strings. For each value, the value is appended to any existing header of the same name, or, if a header does not already exist by the given name, then the header is added.
public addHeaders ( array $headers ) : void
$headers array Associative array of headers to add to the message
return void
    public function addHeaders(array $headers)
    {
        $this->headers = array_merge_recursive($this->headers, $headers);
    }

Usage Example

Example #1
0
 /**
  * @covers \Bluz\Response\Response::setHeaders
  * @covers \Bluz\Response\Response::addHeaders
  * @covers \Bluz\Response\Response::getHeaders
  */
 public function testAddHeaders()
 {
     $this->response->setHeaders(['foo' => ['bar']]);
     $this->response->addHeaders(['foo' => ['baz'], 'baz' => ['qux']]);
     $this->assertEquals(2, sizeof($this->response->getHeaders()));
     $this->assertArrayHasKeyAndSize($this->response->getHeaders(), 'foo', 2);
 }