Completed
Push — master ( 7f3387...0e7ca3 )
by Eric
02:57
created

SymfonyMutator::getPropertyPath()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 6
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 6
loc 6
ccs 0
cts 6
cp 0
rs 9.4285
c 1
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
crap 6
1
<?php
2
3
/*
4
 * This file is part of the Ivory Serializer package.
5
 *
6
 * (c) Eric GELOEN <[email protected]>
7
 *
8
 * For the full copyright and license information, please read the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Ivory\Serializer\Mutator;
13
14
use Symfony\Component\PropertyAccess\PropertyAccess;
15
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
16
17
/**
18
 * @author GeLo <[email protected]>
19
 */
20
class SymfonyMutator implements MutatorInterface
21
{
22
    /**
23
     * @var PropertyAccessorInterface
24
     */
25
    private $propertyAccessor;
26
27
    /**
28
     * @param PropertyAccessorInterface|null $propertyAccessor
29
     */
30
    public function __construct(PropertyAccessorInterface $propertyAccessor = null)
31
    {
32
        $this->propertyAccessor = $propertyAccessor ?: PropertyAccess::createPropertyAccessor();
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function setValue($object, $property, $value)
39
    {
40
        $this->propertyAccessor->setValue($object, $property, $value);
41
    }
42
}
43