StringToImageTransformer::transform()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
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