Total Complexity | 7 |
Total Lines | 74 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
16 | trait Buffered |
||
17 | { |
||
18 | /** |
||
19 | * @var bool[] |
||
20 | */ |
||
21 | private $writable = []; |
||
22 | |||
23 | /** |
||
24 | * @var Promised[] |
||
25 | */ |
||
26 | private $waits = []; |
||
27 | |||
28 | /** |
||
29 | * @param object $sw |
||
30 | * @param int $conn |
||
31 | */ |
||
32 | public function evBufferFull(object $sw, int $conn = 0) : void |
||
|
|||
33 | { |
||
34 | $this->writable[$conn] = false; |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * @param object $sw |
||
39 | * @param int $conn |
||
40 | */ |
||
41 | public function evBufferEmpty(object $sw, int $conn = 0) : void |
||
42 | { |
||
43 | $this->writable[$conn] = true; |
||
44 | if (isset($this->waits[$conn])) { |
||
45 | $wait = $this->waits[$conn]; |
||
46 | unset($this->waits[$conn]); |
||
47 | $wait->resolve($this, $conn); |
||
48 | } |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * @param Closure $do |
||
53 | * @param int $conn |
||
54 | * @return bool |
||
55 | */ |
||
56 | public function ifWritable(Closure $do, int $conn = 0) : bool |
||
77 | } |
||
78 | |||
79 | /** |
||
80 | * @see TCP::write |
||
81 | * @param string $data |
||
82 | * @param int $conn |
||
83 | * @return bool |
||
84 | */ |
||
85 | public function write(string $data, int $conn = 0) : bool |
||
90 | } |
||
91 | } |
||
92 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.