StringToImageTransformer   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A transform() 0 1 1
A reverseTransform() 0 8 2
1
<?php
2
namespace KI\CoreBundle\Transformer;
3
4
use KI\CoreBundle\Service\ImageService;
5
use Symfony\Component\Form\DataTransformerInterface;
6
7
class StringToImageTransformer implements DataTransformerInterface
8
{
9
    protected $imageService;
10
11
    public function __construct(ImageService $imageService)
12
    {
13
        $this->imageService = $imageService;
14
    }
15
16
    // En théorie n'est jamais utilisé
17
    public function transform($image) { return; }
18
19
    public function reverseTransform($base64orUrl)
20
    {
21
        if (!$base64orUrl) {
22
            return null;
23
        }
24
25
        return $this->imageService->upload($base64orUrl);
26
    }
27
}
28