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

Base64Helper   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 0
dl 0
loc 13
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A contentToBase64() 0 10 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