HydratorContext   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Test Coverage

Coverage 64.29%

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 62
ccs 9
cts 14
cp 0.6429
rs 10
c 0
b 0
f 0
wmc 8

5 Methods

Rating   Name   Duplication   Size   Complexity  
A addProperty() 0 3 1
A setClass() 0 3 1
A getProperty() 0 8 4
A getProperties() 0 3 1
A getClass() 0 3 1
1
<?php
2
3
namespace Sf4\Populator;
4
5
class HydratorContext implements HydratorContextInterface
6
{
7
    /**
8
     * Class to hydrate
9
     * @var string
10
     */
11
    protected $class;
12
    /**
13
     * Properties
14
     * @var array
15
     */
16
    protected $properties = array();
17
18
    /**
19
     * {@inheritDoc}
20
     */
21
    public function getClass()
22
    {
23
        return $this->class;
24
    }
25
26
    /**
27
     * Set Class
28
     *
29
     * @param string $class Class to hydrate
30
     */
31 3
    public function setClass($class)
32
    {
33 3
        $this->class = $class;
34 3
    }
35
36
    /**
37
     * Get Properties
38
     *
39
     * @return array
40
     */
41
    public function getProperties()
42
    {
43
        return $this->properties;
44
    }
45
46
    /**
47
     * {@inheritDoc}
48
     */
49 3
    public function getProperty($name): ?PropertyMetadata
50
    {
51 3
        foreach ($this->properties as $property) {
52 3
            if ($name === $property->getName() || $property->hasAlias($name)) {
53 3
                return $property;
54
            }
55
        }
56
        return null;
57
    }
58
59
    /**
60
     * Adds a property
61
     *
62
     * @param PropertyMetadata $property Property Metadata
63
     */
64 3
    public function addProperty(PropertyMetadata $property)
65
    {
66 3
        $this->properties[] = $property;
67 3
    }
68
}
69