Passed
Push — master ( 9ac6fa...c6fd81 )
by Julito
10:12
created

CreateUploadedFile   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 12
rs 10
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\Component\Utils;
8
9
use Symfony\Component\HttpFoundation\File\UploadedFile;
10
11
class CreateUploadedFile
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