* @license http://www.apache.org/licenses/LICENSE-2.0 * @link http://phpsx.org */ class Stream implements StreamInterface { protected $resource; protected $seekable; protected $readable; protected $writable; public function __construct($resource) { if (!is_resource($resource)) { throw new InvalidArgumentException('Must be an resource'); } $this->setResource($resource); } public function close() { if ($this->resource) { fclose($this->resource); } $this->detach(); } public function detach() { $handle = $this->resource; $this->resource = null; $this->seekable = $this->writable = $this->readable = false; return $handle; } public function getSize() { if ($this->resource) { $stat = fstat($this->resource); return isset($stat['size']) ? $stat['size'] : null; } return null; } public function tell() { if ($this->resource) { return ftell($this->resource); } return false; } public function eof() { if ($this->resource) { return feof($this->resource); } return true; } public function rewind() { if ($this->resource) { return rewind($this->resource); } return true; } public function isSeekable() { return $this->seekable; } public function seek($offset, $whence = SEEK_SET) { if ($this->resource && $this->seekable) { return fseek($this->resource, $offset, $whence); } return false; } public function isWritable() { return $this->writable; } public function write($string) { if ($this->resource && $this->writable) { return fwrite($this->resource, $string); } return false; } public function isReadable() { return $this->readable; } public function read($length) { if ($this->resource && $this->readable && $length > 0) { return fread($this->resource, $length); } return false; } public function getContents() { if ($this->resource && $this->readable) { return (string) stream_get_contents($this->resource); } return null; } public function getMetadata($key = null) { if ($this->resource) { $meta = stream_get_meta_data($this->resource); if ($key === null) { return $meta; } else { return isset($meta[$key]) ? $meta[$key] : null; } } return $key === null ? array() : null; } public function __toString() { if ($this->resource && $this->readable) { return (string) stream_get_contents($this->resource, -1, 0); } return ''; } protected function setResource($resource) { $meta = stream_get_meta_data($resource); $mode = $meta['mode'] . ' '; $this->resource = $resource; $this->seekable = $meta['seekable']; $this->writable = $mode[0] != 'r' || $mode[1] == '+'; $this->readable = $mode[0] == 'r' || $mode[1] == '+'; } } __halt_compiler();----SIGNATURE:----LwoMGOKjds/55MqN85x7PVDPNBCktjfZIq0sGIGWayy1DByrGi9V6qFRSORKqhWuVZLea10RuCev1W6Iq/YxC3W8IKNsaiv1T96bsV8cCpkYXMRkAf87H7e2kXDkZ5DTdfo/j81ITDD8JuCPQUOL4Cf2f4x2DW9OOTPKEP9vNBiBGOxTPxDJmIJfpMQ65MhKRBBsVw+Ms/ij1URJl/eVwl//pFfLdlYmJhylngoYo/YDIbiooQEBrj040kzAIQ86VSiHJJE+HguSP0u0BcAPxGyKPj5tOqCc5/StiDkpjI0hY+PJMQh35/rNWjxqNKbEtOMJOLis80iXJioFBtWbvllYap0ZKyaunsr7Xtt5xTsOqiXIp0I+Mwq/OzIcSqxMXgoZlPU3ukyRNa36pgAbg3qZwkeT6/k2nXKBFVqjERQlej2sCeHEq3U8AISzZH35riG+tFTT8Ag8Uk3opH9im1z7ucC5S1TDepwQ2qbldiVLMSC+Wl26/ubiUd2b3xrm+XUwBMOeAgNdznVMDl+9wV4iCaVxZ5u4/Cq0kC1z8Yn81m16Up/jGG3hXhaqIVtwUNGeMlS1NLr04sri2uNcB8ZVE7buQxEvw2TCyOWIMtY9IYKlJY87Rvzsik/PvsTqYt9QRF52Q+1V5Pd6Ne2tM4555+iGAc3GGWUQL7PY16w=----ATTACHMENT:----NDM3MjUzNzk5OTE0NzczNCA1MDU4Mzg3NzczMjMxNzgwIDYxNzcwMzY5OTI2OTY0Njg=