SymfonyMutator::setValue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
ccs 0
cts 4
cp 0
rs 10
cc 1
nc 1
nop 3
crap 2
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