Code Duplication    Length = 3-3 lines in 3 locations

models/types/Media.php 2 locations

@@ 47-49 (lines=3) @@
44
        $tmpFilepath = tempnam(sys_get_temp_dir(), 'LCDS_');
45
46
        if ($this->upload->saveAs($tmpFilepath)) {
47
            if (static::validateFile($tmpFilepath)) {
48
                return ['filename' => $filename, 'tmppath' => $tmpFilepath, 'duration' => static::getDuration($tmpFilepath)];
49
            }
50
            $this->addError('load', Yii::t('app', 'Invalid file'));
51
            unlink($tmpFilepath);
52
@@ 131-133 (lines=3) @@
128
        $fileInstance->size = $this->_size;
129
        $this->upload = $fileInstance;
130
131
        if (static::validateFile($fileInstance->tempName)) {
132
            return ['filename' => $filename, 'tmppath' => $tmpFilepath, 'duration' => static::getDuration($tmpFilepath)];
133
        }
134
135
        $this->addError('load', Yii::t('app', 'Invalid file'));
136
        unlink($fileInstance->tempName);

models/types/HostedVideo.php 1 location

@@ 78-80 (lines=3) @@
75
        $fileInstance->size = $video->getFile()->getSize();
76
        $this->upload = $fileInstance;
77
78
        if (static::validateFile($fileInstance->tempName)) {
79
            return ['filename' => $filename, 'tmppath' => $tmpFilepath, 'duration' => static::getDuration($tmpFilepath)];
80
        }
81
82
        $this->addError('load', Yii::t('app', 'Invalid file'));
83
        unlink($fileInstance->tempName);