Passed
Pull Request — master (#6396)
by Angel Fernando Quiroz
08:39
created

CreateUploadedFileHelper   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 12
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A fromString() 0 10 1
1
<?php
2
3
declare(strict_types=1);
4
5
/* For licensing terms, see /license.txt */
6
7
namespace Chamilo\CoreBundle\Helpers;
8
9
use Symfony\Component\HttpFoundation\File\UploadedFile;
10
11
class CreateUploadedFileHelper
12
{
13
    public static function fromString(string $fileName, string $mimeType, string $content): UploadedFile
14
    {
15
        /*$handle = tmpfile();
16
        fwrite($handle, $content);
17
        $meta = stream_get_meta_data($handle);*/
18
19
        $tmpFilename = tempnam(sys_get_temp_dir(), 'resource_file_');
20
        file_put_contents($tmpFilename, $content);
21
22
        return new UploadedFile($tmpFilename, $fileName, $mimeType, null, true);
23
    }
24
}
25