You are here

public function Stream::getMetadata in Zircon Profile 8

Same name in this branch
  1. 8 vendor/zendframework/zend-diactoros/src/Stream.php \Zend\Diactoros\Stream::getMetadata()
  2. 8 vendor/guzzlehttp/psr7/src/Stream.php \GuzzleHttp\Psr7\Stream::getMetadata()
  3. 8 vendor/symfony/psr-http-message-bridge/Tests/Fixtures/Stream.php \Symfony\Bridge\PsrHttpMessage\Tests\Fixtures\Stream::getMetadata()
Same name and namespace in other branches
  1. 8.0 vendor/zendframework/zend-diactoros/src/Stream.php \Zend\Diactoros\Stream::getMetadata()

Get stream metadata as an associative array or retrieve a specific key.

The keys returned are identical to the keys returned from PHP's stream_get_meta_data() function.

@link http://php.net/manual/en/function.stream-get-meta-data.php

Parameters

string $key Specific metadata to retrieve.:

Return value

array|mixed|null Returns an associative array if no key is provided. Returns a specific key value if a key is provided and the value is found, or null if the key is not found.

Overrides StreamInterface::getMetadata

File

vendor/zendframework/zend-diactoros/src/Stream.php, line 278

Class

Stream
Implementation of PSR HTTP streams

Namespace

Zend\Diactoros

Code

public function getMetadata($key = null) {
  if (null === $key) {
    return stream_get_meta_data($this->resource);
  }
  $metadata = stream_get_meta_data($this->resource);
  if (!array_key_exists($key, $metadata)) {
    return null;
  }
  return $metadata[$key];
}