| @@ 74-95 (lines=22) @@ | ||
| 71 | /** |
|
| 72 | * @param Url $url |
|
| 73 | */ |
|
| 74 | public function push(Url $url) |
|
| 75 | { |
|
| 76 | if (!$this->state->isReady()) { |
|
| 77 | throw StreamStateException::notReady(); |
|
| 78 | } |
|
| 79 | ||
| 80 | if ($this->counter >= self::LINKS_LIMIT) { |
|
| 81 | throw LinksOverflowException::withLimit(self::LINKS_LIMIT); |
|
| 82 | } |
|
| 83 | ||
| 84 | $render_url = $this->render->url($url); |
|
| 85 | $expected_bytes = $this->used_bytes + strlen($render_url) + strlen($this->end_string); |
|
| 86 | ||
| 87 | if ($expected_bytes > self::BYTE_LIMIT) { |
|
| 88 | throw SizeOverflowException::withLimit(self::BYTE_LIMIT); |
|
| 89 | } |
|
| 90 | ||
| 91 | $this->send($render_url); |
|
| 92 | ++$this->counter; |
|
| 93 | } |
|
| 94 | ||
| 95 | /** |
|
| 96 | * @return int |
|
| 97 | */ |
|
| 98 | public function count() |
|
| @@ 117-136 (lines=20) @@ | ||
| 114 | /** |
|
| 115 | * @param Url $url |
|
| 116 | */ |
|
| 117 | public function push(Url $url) |
|
| 118 | { |
|
| 119 | if (!$this->state->isReady()) { |
|
| 120 | throw StreamStateException::notReady(); |
|
| 121 | } |
|
| 122 | ||
| 123 | if ($this->counter >= self::LINKS_LIMIT) { |
|
| 124 | throw LinksOverflowException::withLimit(self::LINKS_LIMIT); |
|
| 125 | } |
|
| 126 | ||
| 127 | $render_url = $this->render->url($url); |
|
| 128 | ||
| 129 | $expected_bytes = $this->used_bytes + strlen($render_url) + strlen($this->end_string); |
|
| 130 | if ($expected_bytes > self::BYTE_LIMIT) { |
|
| 131 | throw SizeOverflowException::withLimit(self::BYTE_LIMIT); |
|
| 132 | } |
|
| 133 | ||
| 134 | $this->write($render_url); |
|
| 135 | ++$this->counter; |
|
| 136 | } |
|
| 137 | ||
| 138 | /** |
|
| 139 | * @return int |
|