PluginProbe
ManageWP Worker / 4.9.25
ManageWP Worker v4.9.25
4.9.38 4.9.37 4.9.36 4.9.35 4.9.34 3.8.7 3.8.8 3.9.0 3.9.1 3.9.10 3.9.11 3.9.12 3.9.13 3.9.14 3.9.15 3.9.16 3.9.17 3.9.18 3.9.19 3.9.2 3.9.20 3.9.21 3.9.22 3.9.23 3.9.24 All 73 releases
worker / src / MWP / Stream / Decorator.php

Decorator.php in ManageWP Worker 4.9.25, at src/MWP/Stream/Decorator.php

105 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 * This file is part of the ManageWP Worker plugin.
4 *
5 * (c) ManageWP LLC <contact@managewp.com>
6 *
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
9 */
10
11 abstract class MWP_Stream_Decorator implements MWP_Stream_Interface
12 {
13
14 private $initialized = false;
15
16 /**
17 * @var MWP_Stream_Interface
18 */
19 private $stream;
20
21 public function __construct(MWP_Stream_Interface $stream = null)
22 {
23 $this->stream = $stream;
24
25 if ($this->stream) {
26 $this->initialized = true;
27 }
28 }
29
30 protected function getStream()
31 {
32 if (!$this->stream) {
33 $this->stream = $this->createStream();
34 }
35
36 return $this->stream;
37 }
38
39 protected function createStream()
40 {
41 return null;
42 }
43
44 /**
45 * Closes the stream and any underlying resources.
46 */
47 public function close()
48 {
49 $this->getStream()->close();
50 }
51
52 /**
53 * Returns the current position of the file read/write pointer
54 *
55 * @return int|bool Returns the position of the file pointer or false on error
56 */
57 public function tell()
58 {
59 return $this->getStream()->tell();
60 }
61
62 /**
63 * @return bool
64 */
65 public function isSeekable()
66 {
67 return $this->getStream()->isSeekable();
68 }
69
70 /**
71 * @param int $offset
72 * @param int $whence
73 *
74 * @return bool
75 */
76 public function seek($offset, $whence = SEEK_SET)
77 {
78 return $this->getStream()->seek($offset, $whence);
79 }
80
81 /**
82 * Returns true if the stream is at the end of the stream.
83 *
84 * @return bool
85 */
86 public function eof()
87 {
88 return $this->getStream()->eof();
89 }
90
91 /**
92 * Read data from the stream
93 *
94 * @param int $length Read up to $length bytes from the object and return
95 * them. Fewer than $length bytes may be returned if
96 * underlying stream call returns fewer bytes.
97 *
98 * @return string Returns the data read from the stream.
99 */
100 public function read($length)
101 {
102 return $this->getStream()->read($length);
103 }
104 }
105