Code Duplication    Length = 22-22 lines in 2 locations

code/blocks/slider/models/VideoSliderItem.php 1 location

@@ 247-268 (lines=22) @@
244
     *
245
     * @return bool|string
246
     */
247
    public function getEmbedLink() {
248
        if (! empty($this->URL) && $this->Type != 'File') {
249
            try {
250
                $videoId = BlocksUtility::parse_video_id($this->URL, $this->Type);
251
            } catch (ProviderNotFound $ex) {
252
                return false;
253
            }
254
255
            if ($videoId && array_key_exists($this->Type, ($options = static::config()->embed_links))) {
256
                $options = $options[$this->Type];
257
                $autoPlay = array_key_exists("AutoPlay", $options) && ! empty($options["AutoPlay"]) ? $options["AutoPlay"] : '';
258
259
                return str_replace(
260
                    ['{VideoId}', '{AutoPlay}'],
261
                    [$videoId, $autoPlay],
262
                    $options["Link"]
263
                );
264
            }
265
        }
266
267
        return false;
268
    }
269
270
    /**
271
     * @return \ValidationResult

code/blocks/video/models/VideoBlock.php 1 location

@@ 199-220 (lines=22) @@
196
     *
197
     * @return bool|string
198
     */
199
    public function getEmbedLink() {
200
        if (! empty($this->URL) && $this->Type != 'File') {
201
            try {
202
                $videoId = BlocksUtility::parse_video_id($this->URL, $this->Type);
203
            } catch (ProviderNotFound $ex) {
204
                return false;
205
            }
206
207
            if ($videoId && array_key_exists($this->Type, ($options = VideoSliderItem::config()->embed_links))) {
208
                $options = $options[$this->Type];
209
                $autoPlay = array_key_exists("AutoPlay", $options) && ! empty($options["AutoPlay"]) ? $options["AutoPlay"] : '';
210
211
                return str_replace(
212
                    ['{VideoId}', '{AutoPlay}'],
213
                    [$videoId, $autoPlay],
214
                    $options["Link"]
215
                );
216
            }
217
        }
218
219
        return false;
220
    }
221
222
    /**
223
     * @return \ValidationResult