HydratorContext::getClass()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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