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

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

src/Stream/RenderFileStream.php 1 location

@@ 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

src/Stream/RenderGzipFileStream.php 1 location

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