Completed
Push — master ( 762d42...ac66df )
by Саша
10:39
created

PropertyTransformer::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 10
rs 9.4285
cc 1
eloc 7
nc 1
nop 3
1
<?php
2
3
namespace Extraload\Transformer;
4
5
use Extraload\Transformer\TransformerInterface;
6
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
7
8
class PropertyTransformer implements TransformerInterface
9
{
10
    private $transformer;
11
    private $propertyAccessor;
12
    private $path;
13
14
    public function __construct(
15
        TransformerInterface $transformer,
16
        PropertyAccessorInterface $propertyAccessor,
17
        $path
18
    )
19
    {
20
        $this->transformer = $transformer;
21
        $this->propertyAccessor = $propertyAccessor;
22
        $this->path = $path;
23
    }
24
25
    public function transform($data)
26
    {
27
        $this->propertyAccessor->setValue(
28
            $data,
29
            $this->path,
30
            $this->transformer->transform(
31
                $this->propertyAccessor->getValue($data, $this->path)
32
            )
33
        );
34
35
        return $data;
36
    }
37
}
38