You are here

public function Stream::getMetadata in Lockr 7.3

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

1 call to Stream::getMetadata()
Stream::__construct in vendor/guzzlehttp/psr7/src/Stream.php
This constructor accepts an associative array of options.

File

vendor/guzzlehttp/psr7/src/Stream.php, line 256

Class

Stream
PHP stream implementation.

Namespace

GuzzleHttp\Psr7

Code

public function getMetadata($key = null) {
  if (!isset($this->stream)) {
    return $key ? null : [];
  }
  elseif (!$key) {
    return $this->customMetadata + stream_get_meta_data($this->stream);
  }
  elseif (isset($this->customMetadata[$key])) {
    return $this->customMetadata[$key];
  }
  $meta = stream_get_meta_data($this->stream);
  return isset($meta[$key]) ? $meta[$key] : null;
}