Bluz\Response\Response::getHeaderAsArray PHP Method

getHeaderAsArray() public method

Retrieves a header by the given case-insensitive name as an array of strings
public getHeaderAsArray ( string $header ) : string[]
$header string Case-insensitive header name.
return string[]
    public function getHeaderAsArray($header)
    {
        if ($this->hasHeader($header)) {
            return $this->headers[$header];
        } else {
            return [];
        }
    }

Usage Example

Example #1
0
 /**
  * @covers \Bluz\Response\Response::addHeader
  * @covers \Bluz\Response\Response::getHeader
  * @covers \Bluz\Response\Response::getHeaderAsArray
  */
 public function testAddHeader()
 {
     $this->response->addHeader('foo', 'bar');
     $this->response->addHeader('foo', 'baz');
     $this->assertTrue($this->response->hasHeader('foo'));
     $this->assertEquals('bar, baz', $this->response->getHeader('foo'));
     $this->assertEqualsArray(['bar', 'baz'], $this->response->getHeaderAsArray('foo'));
     $this->assertEqualsArray([], $this->response->getHeaderAsArray('baz'));
 }