| Total Complexity | 6 |
| Total Lines | 65 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | class Connection extends NET implements Stream |
||
| 16 | { |
||
| 17 | /** |
||
| 18 | * @var TCP |
||
| 19 | */ |
||
| 20 | private $sock = null; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @var string |
||
| 24 | */ |
||
| 25 | private $data = null; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @param TCP $sock |
||
| 29 | * @return Stream |
||
| 30 | */ |
||
| 31 | public function from(TCP $sock) : Stream |
||
| 32 | { |
||
| 33 | $this->sock = $sock; |
||
| 34 | return $this; |
||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @param string $data |
||
| 39 | * @return self |
||
| 40 | */ |
||
| 41 | public function setReceived(string $data) : self |
||
| 42 | { |
||
| 43 | $this->data = $data; |
||
| 44 | return $this; |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * |
||
| 49 | * @return string |
||
| 50 | */ |
||
| 51 | public function recv() : string |
||
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * @param string $data |
||
| 58 | * @return bool |
||
| 59 | */ |
||
| 60 | public function write(string $data) : bool |
||
| 63 | } |
||
| 64 | |||
| 65 | /** |
||
| 66 | * @param string $data |
||
| 67 | * @return bool |
||
| 68 | */ |
||
| 69 | public function send(string $data) : bool |
||
| 70 | { |
||
| 71 | return $this->sock->send($data, $this->id); |
||
| 72 | } |
||
| 73 | |||
| 74 | /** |
||
| 75 | * @return bool |
||
| 76 | */ |
||
| 77 | public function close() : bool |
||
| 80 | } |
||
| 81 | } |
||
| 82 |