WorkflowDtoTransformer   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 20
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A transform() 0 3 1
A supportsTransformation() 0 7 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * (c) 2019, Wesley O. Nichols
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Wesnick\WorkflowBundle\Transformer;
13
14
use ApiPlatform\Core\DataTransformer\DataTransformerInterface;
15
use Wesnick\WorkflowBundle\Model\WorkflowDTO;
16
17
/**
18
 * Class WorkflowDtoTransformer.
19
 *
20
 * @author Wesley O. Nichols <[email protected]>
21
 */
22
class WorkflowDtoTransformer implements DataTransformerInterface
23
{
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function transform($data, string $to, array $context = [])
28
    {
29
        return $data;
30
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35
    public function supportsTransformation($data, string $to, array $context = []): bool
36
    {
37
        if (is_object($data)) {
38
            return false;
39
        }
40
41
        return WorkflowDTO::class === ($context['input']['class'] ?? null);
42
    }
43
}
44