Code Duplication    Length = 20-20 lines in 4 locations

src/Stream/OutputStream.php 1 location

@@ 74-93 (lines=20) @@
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

src/Stream/RenderBzip2FileStream.php 1 location

@@ 130-149 (lines=20) @@
127
    /**
128
     * @param Url $url
129
     */
130
    public function push(Url $url)
131
    {
132
        if (!$this->state->isReady()) {
133
            throw StreamStateException::notReady();
134
        }
135
136
        if ($this->counter >= self::LINKS_LIMIT) {
137
            throw LinksOverflowException::withLimit(self::LINKS_LIMIT);
138
        }
139
140
        $render_url = $this->render->url($url);
141
142
        $expected_bytes = $this->used_bytes + strlen($render_url) + strlen($this->end_string);
143
        if ($expected_bytes > self::BYTE_LIMIT) {
144
            throw SizeOverflowException::withLimit(self::BYTE_LIMIT);
145
        }
146
147
        $this->write($render_url);
148
        ++$this->counter;
149
    }
150
151
    /**
152
     * @return int

src/Stream/RenderFileStream.php 1 location

@@ 126-145 (lines=20) @@
123
    /**
124
     * @param Url $url
125
     */
126
    public function push(Url $url)
127
    {
128
        if (!$this->state->isReady()) {
129
            throw StreamStateException::notReady();
130
        }
131
132
        if ($this->counter >= self::LINKS_LIMIT) {
133
            throw LinksOverflowException::withLimit(self::LINKS_LIMIT);
134
        }
135
136
        $render_url = $this->render->url($url);
137
138
        $expected_bytes = $this->used_bytes + strlen($render_url) + strlen($this->end_string);
139
        if ($expected_bytes > self::BYTE_LIMIT) {
140
            throw SizeOverflowException::withLimit(self::BYTE_LIMIT);
141
        }
142
143
        $this->write($render_url);
144
        ++$this->counter;
145
    }
146
147
    /**
148
     * @return int

src/Stream/RenderGzipFileStream.php 1 location

@@ 138-157 (lines=20) @@
135
    /**
136
     * @param Url $url
137
     */
138
    public function push(Url $url)
139
    {
140
        if (!$this->state->isReady()) {
141
            throw StreamStateException::notReady();
142
        }
143
144
        if ($this->counter >= self::LINKS_LIMIT) {
145
            throw LinksOverflowException::withLimit(self::LINKS_LIMIT);
146
        }
147
148
        $render_url = $this->render->url($url);
149
150
        $expected_bytes = $this->used_bytes + strlen($render_url) + strlen($this->end_string);
151
        if ($expected_bytes > self::BYTE_LIMIT) {
152
            throw SizeOverflowException::withLimit(self::BYTE_LIMIT);
153
        }
154
155
        $this->write($render_url);
156
        ++$this->counter;
157
    }
158
159
    /**
160
     * @return int