Completed
Push — master ( 607289...edbd19 )
by Pavel
01:31
created

AssociationPropertyAccessor   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 58.81%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 53
ccs 10
cts 17
cp 0.5881
rs 10
c 1
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A setValue() 0 6 1
A getValue() 0 8 1
A isWritable() 0 4 1
A isReadable() 0 4 1
1
<?php
2
3
namespace ScayTrase\Api\Cruds\Adaptors\DoctrineOrm;
4
5
use Symfony\Bridge\Doctrine\ManagerRegistry;
6
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
7
8
final class AssociationPropertyAccessor implements PropertyAccessorInterface
9
{
10
    /** @var  PropertyAccessorInterface */
11
    private $delegate;
12
    /** @var  ManagerRegistry */
13
    private $registry;
14
    /** @var  AssociationNormalizer */
15
    private $normalizer;
16
17
    /**
18
     * AssociationPropertyAccessor constructor.
19
     *
20
     * @param PropertyAccessorInterface $delegate
21
     * @param ManagerRegistry           $registry
22
     */
23 6
    public function __construct(PropertyAccessorInterface $delegate, ManagerRegistry $registry)
24
    {
25 6
        $this->delegate = $delegate;
26 6
        $this->registry = $registry;
27
28 6
        $this->normalizer = new AssociationNormalizer($this->registry);
29 6
    }
30
31
    /** {@inheritdoc} */
32
    public function setValue(&$objectOrArray, $propertyPath, $value)
33
    {
34
        $value = $this->normalizer->denormalize($objectOrArray, $propertyPath, $value);
35
36
        return $this->delegate->setValue($objectOrArray, $propertyPath, $value);
37
    }
38
39
    /** {@inheritdoc} */
40 5
    public function getValue($objectOrArray, $propertyPath)
41
    {
42 5
        return $this->normalizer->normalize(
43 5
            $this->delegate->getValue($objectOrArray, $propertyPath),
44 5
            $objectOrArray,
45
            $propertyPath
46 5
        );
47
    }
48
49
    /** {@inheritdoc} */
50
    public function isWritable($objectOrArray, $propertyPath)
51
    {
52
        return $this->delegate->isWritable($objectOrArray, $propertyPath);
53
    }
54
55
    /** {@inheritdoc} */
56
    public function isReadable($objectOrArray, $propertyPath)
57
    {
58
        return $this->delegate->isReadable($objectOrArray, $propertyPath);
59
    }
60
}
61