Completed
Push — master ( ecd748...4c1df3 )
by Benoit
12:53 queued 02:55
created

Base64Helper::contentToBase64()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Presta\ImageBundle\Helper;
4
5
trait Base64Helper
6
{
7
    private function contentToBase64(string $content): string
8
    {
9
        $imageData = file_get_contents($content);
10
        $imageInfo = getimagesizefromstring($imageData);
11
        $mimeType = $imageInfo['mime'] ?? 'image/png';
12
13
        $base64 = base64_encode($imageData);
14
15
        return "data:$mimeType;base64,$base64";
16
    }
17
}
18